-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
52 lines (44 loc) · 1.35 KB
/
server.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
//Import Express
const express = require('express');
const dotenv = require('dotenv');
const mongoose = require('mongoose');
const cookieParser = require('cookie-parser');
dotenv.config();
//Initializing Server and Port
const server = express();
const PORT = 8080;
//Connect to DataBase
mongoose.connect(
process.env.YOUR_DB_KEY, {
useNewUrlParser: true,
useUnifiedTopology: true
},
() => {
console.log('*** Connected with DataBase!!! ***')
});
//Server Setup
server.set('views', './source/views');
server.set('view engine', 'ejs');
server.use(cookieParser());
server.use(express.json());
server.use(express.static('./source/public'));
server.use(express.urlencoded({
extended: true
}));
//Route Imports
let homeRoute = require('./source/routes/index.js');
let profileRoute = require('./source/routes/profile');
//Route Imports for REST Api
let authRoute = require('./source/routes/api/user.js');
let clipboardRoute = require('./source/routes/api/clipboard.js');
let taskRoute = require('./source/routes/api/task.js');
//Using Route Imports
server.use('/', homeRoute);
server.use('/profile', profileRoute);
server.use('/api/user', authRoute);
server.use('/api/clipboard', clipboardRoute);
server.use('/api/task', taskRoute);
//Server Listening to Requests!!!
server.listen(PORT, () => {
console.log(`*** Server is running on: localhost:${PORT} ***`);
});