-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
53 lines (43 loc) · 1.13 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const express = require("express");
// console.log(express);
const app = express();
const port = 5000;
const web = require("./routes/web");
const connectDb = require("./db/connectdb");
const cookieParser=require('cookie-parser')
//file upload
const fileupload=require('express-fileupload')
const bodyParser = require("body-parser");
//file upload
app.use(fileupload({useTempFiles:true}))
//token get
app.use(cookieParser());
//connect db
connectDb();
// Middleware
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.urlencoded({ extended: false }));
//connect flash and session
const session = require('express-session')
const flash = require('connect-flash');
// const fileUpload = require("express-fileupload");
//message
app.use(session({
secret: 'secret',
cookie: { maxAge: 60000 },
resave: flash,
saveUninitialized: flash
}))
//flash message
app.use(flash())
//html css views
app.set("view engine", "ejs");
//html css link in file
app.use(express.static("public"));
//route load
app.use("/", web);
// server create
app.listen(port, () => {
console.log("Server start locathost:5000");
});