This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
78 lines (64 loc) · 1.41 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* @requires express
* @requires express-session
* @requires userRouter
* @requires body-parser
* @requires dotenv
* @requires mongoose
*/
/**
* Used port.
*/
const port = 3001;
/**
* UserRouter module
*/
const userRouter = require('./routes/userRouter');
/**
* Express module
* @const
* @source https://expressjs.com/en/api.html
*/
const express = require('express');
const app = express();
/**
* Express-session module
* @const
* @source https://github.com/expressjs/session
*/
const session = require('express-session');
/**
* Dotenv module
* @source https://github.com/motdotla/dotenv
*/
require('dotenv').config();
/**
* Body-parser module
* @const
* @source https://github.com/expressjs/body-parser
*/
const bodyParser = require('body-parser');
/**
* Mongoose module
* @const
* @source https://github.com/Automattic/mongoose
*/
const mongoose = require('mongoose');
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
}),
);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
mongoose.set('useNewUrlParser', true);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.set('useUnifiedTopology', true);
mongoose.connect(process.env.DB_URL);
app.use('/', userRouter);
app.listen(port);