-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (29 loc) · 912 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
34
35
36
37
38
const path = require("path");
require("dotenv").config({ path: path.join(__dirname, ".env") });
const express = require('express');
const bodyParser = require("body-parser");
const session = require('express-session');
const db = require('./config/db');
const response = require('./utils/response');
const routes = require('./routes');
const PORT = process.env.PORT || 3000;
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(
session({
resave: false,
saveUninitialized: false,
secret: "secret",
cookie: { maxAge: 604800000 }
})
);
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));
app.use(express.static(path.join(__dirname, "public")));
app.use(response);
app.use('/', routes);
db.connectMongo();
app.listen(PORT, (err) => {
console.log(err || `Listening on port ${PORT}`);
})