-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (38 loc) · 1.11 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
const express = require('express')
const app = express()
const dotenv = require('dotenv');
const mongoose = require('mongoose');
dotenv.config();
app.set('view engine', 'ejs');
//* Middleware
app.use(express.static('public'));
app.use(express.json());
app.use(express.urlencoded({
extended: true
}))
//* Connect to DB
mongoose.connect(
process.env.DB_URL, {
useUnifiedTopology: true,
useNewUrlParser: true,
},
console.log('Connect to DB'),
)
//* Listen to PORT:3000
let server = app.listen(3000, () => {
console.log('Up and Running at http://localhost:', server.address().port)
});
//* Assign controllers
const index = require('./controllers/logIn');
app.use('', index);
const register = require('./controllers/register');
app.use('/register', register);
const home = require('./controllers/home');
app.use('/home', home);
const encrypt = require('./controllers/encrypt');
app.use('/encrypt', encrypt);
const decrypt = require('./controllers/decrypt');
app.use('/decrypt', decrypt);
const generate = require('./controllers/generate');
app.use('/generate', generate);
module.exports = app;