Skip to content

Instantly share code, notes, and snippets.

@abhishekr700
Last active February 10, 2018 07:19
Show Gist options
  • Save abhishekr700/e2ea5153c8cd600169fe456b6760e7a7 to your computer and use it in GitHub Desktop.
Save abhishekr700/e2ea5153c8cd600169fe456b6760e7a7 to your computer and use it in GitHub Desktop.
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}`);
});
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