//npm modules
const express = require('express');
const uuid = require('uuid/v4')
const session = require('express-session')
// create the server
const app = express();
// add & configure middleware
app.use(session({
genid: (req) => {
console.log('Inside the session middleware')
console.log(req.sessionID)
return uuid() // use UUIDs for session IDs
},
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
}))
// create the homepage route at '/'
app.get('/', (req, res) => {
console.log('Inside the homepage callback function')
console.log(req.sessionID)
res.send(`You hit home page!\n`)
})
// tell the server what port to listen on
app.listen(3000, () => {
console.log('Listening on localhost:3000')
})
Last active
October 29, 2017 20:49
-
-
Save evangow/52683cf8d4b2f25632aa3ad3a7cb2cf3 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment