Last active
February 10, 2018 07:19
-
-
Save abhishekr700/e2ea5153c8cd600169fe456b6760e7a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const session = require("express-session"); | |
const app = express(); | |
app.use(express.json()); | |
app.use(express.urlencoded({ | |
extended: true | |
})); | |
//Handle sessions | |
let sessionMiddleware = session({ | |
resave: true, | |
saveUninitialized: false, | |
secret: "Boli_Lagegi", | |
store: store, | |
//if maxAge not set, cookie valid for current session only(until browser restart) | |
cookie: { | |
maxAge: 1000 * 60 * 60 * 24 * 10 //10 days | |
}, | |
}) | |
app.use(sessionMiddleware); | |
app.use("/info", require("./routes/info")); | |
//Listen on port | |
app.listen(CONFIG.SERVER.PORT, function () { | |
someFunctionToCallOnServerStart(); | |
console.log(`Server running @ http://${CONFIG.SERVER.HOST}:${CONFIG.SERVER.PORT}`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const route = require("express").Router(); | |
route.get("/", (req, res) => { | |
res.send("info"); | |
}); | |
module.exports = route; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment