-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (23 loc) · 804 Bytes
/
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
const express = require('express');
const db = require('./config/mongoose');
const port = process.env.PORT || 3000;
const app = express();
const path = require('path');
const expressLayouts = require('express-ejs-layouts');
app.use(express.urlencoded({extended: true}));
app.use(express.static('assets'));
app.use(expressLayouts);
// extract style and scripts from sub pages into the layout
app.set('layout extractStyles', true);
app.set('layout extractScripts', true);
// set up the view engine
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/views'));
// use express router
app.use('/', require('./routes'));
app.listen(port, function (err) {
if (err) {
console.log(`Error in running the server: ${err}`);
}
console.log(`Server is running on port: ${port}`);
});