Sunday 22 July 2018

code review please?

hello! I started learning node about 3 days ago... I'm working on my first node app... this is what I have so far.... any tips/input/suggestions? thanks...'use strict'; const ejs = require('ejs'); const express = require('express'); const session = require('express-session'); const bodyParser = require('body-parser'); const MongoDBStore = require('connect-mongodb-session')(session); const index = require('./routes/index'); const api = require('./routes/api'); const app = express(); app.set('view engine', 'ejs'); app.use(express.static(__dirname + '/public')); app.use(bodyParser.urlencoded({ extended: false })); var store = new MongoDBStore({ uri: 'mongodb://localhost:27017/securebox', collection: 'sessions' }); store.on('connected', () => store.client ); app.use(session({ secret: 'lot of random chars here my dude', cookie: { maxAge: 365 * 24 * 60 * 60 * 1000 }, resave: false, saveUninitialized: false, store: store })); app.use('/', index); app.use('/api', api); app.listen(3000);

Submitted July 22, 2018 at 09:03AM by superfake123

No comments:

Post a Comment