Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const router = express.Router();
- const nodemailer = require("nodemailer");
- router.use('/superMiddleware', function (req, res, next) {
- console.log("Hello middleware");
- next();
- }, function (req, res, next) {
- res.send('Hello world');
- next();
- });
- router.get('/askForCookiesRecipe', (req, res, next) => {
- // Création de la méthode de transport de l'email
- const smtpTransport = nodemailer.createTransport("SMTP", {
- service: "Gmail",
- auth: {
- user: "maGrandMa@gmail.com",
- pass: "userPass"
- }
- });
- smtpTransport.sendMail({
- from: "Deer Wild <deer@wild.com>", // Expediteur
- to: "wildCodeSchool@hotmail.com", // Destinataires
- subject: "Coucou !", // Sujet
- text: "Hello world ✔", // plaintext body
- html: "<b>Hello world ✔</b>" // html body
- }, (error, response) => {
- if (error) {
- console.log(error);
- } else {
- console.log("Message sent: " + response.message);
- }
- });
- });
- /* GET Session in. */
- router.get('/session-in', (req, res, next) => {
- // Initialisation de la variable de sessions "song"
- req.session.song = "be bop a lula";
- console.log(req.session.song);
- res.end();
- });
- /* GET Session out. */
- router.get('/session-out', (req, res, next) => {
- res.send(`the song is ${req.session.song}`);
- next();
- });
- /* GET home page. */
- router.get('/', function (req, res, next) {
- res.render('index', {
- title: 'Express'
- });
- next();
- });
- module.exports = router;
Add Comment
Please, Sign In to add comment