Skip to content

Instantly share code, notes, and snippets.

@soner8
Created April 9, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soner8/7132ed295c1ca4f343d87f3f7a53816c to your computer and use it in GitHub Desktop.
Save soner8/7132ed295c1ca4f343d87f3f7a53816c to your computer and use it in GitHub Desktop.
node.js
var express = require('express');
var router = express.Router();
var cookieParser = require('cookie-parser');
var session = require('express-session');
var app = express();
/* GET home page. */
router.get('/', function (req, res) {
res.render('index', {
title: 'Express'
});
});
router.use('/superMiddleware', function (req, res, next) {
console.log('Hello middleware');
next();
}, function (req, res, next){
res.send('hello world');
});
router.get('/sessionIn', (req, res) => {
req.session.song = 'be bop a lula';
res.end();
});
router.get('/sessionOut', function (req, res){
res.send(req.session.song);
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment