-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (27 loc) · 790 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
methodOverride = require("method-override"),
flash = require("connect-flash");
var indexRoutes =require("./routes/index");
app.use(bodyParser.urlencoded({extended:true}));
app.set("view engine", "ejs");
app.use(express.static(__dirname+"/public/"));
app.use(flash());
app.use(methodOverride("_method"));
app.use(require("express-session")({
secret:"bookstore",
resave:false,
saveUniniatialized:false
}));
app.use(function (req, res, next) {
res.locals.user = req.session.user;
res.locals.error=req.flash("error");
res.locals.success=req.flash("success");
next();
});
// ROUTES
app.use(indexRoutes);
app.listen(3000,function(){
console.log("SERVER STARTED!!!");
});