Last active
July 18, 2016 17:41
-
-
Save stevenspads/177a15844365f8fa66d9a0b4a8d8e238 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
//In the terminal, go to your project folder and run the following: | |
$ npm install --save express-validator | |
$ npm install --save express-session | |
//----------------------------------- | |
//Go to your app.js file, and make sure it reads as follows: | |
//----------------------------------- | |
var express = require('express'); | |
... | |
var expressValidator = require('express-validator'); /*** require Form Validator ***/ | |
var expressSession = require('express-session'); /*** require Session ***/ | |
var routes = require('./routes/index'); | |
var app = express(); | |
... | |
/* Middlewares */ | |
app.use(logger('dev')); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
/*** use Form Validator ***/ | |
app.use(expressValidator()); | |
app.use(cookieParser()); | |
app.use(express.static(path.join(__dirname, 'public'))); //load public css,js statically thru import in html code | |
/*** Use Session management ***/ | |
app.use(expressSession({secret: 'test', saveUninitialized: false, resave: false})); | |
//resave true saves session after each request even if session not initialized | |
app.use('/', routes); | |
app.use('/users', users); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment