-
Notifications
You must be signed in to change notification settings - Fork 150
/
index.js
38 lines (20 loc) · 1.03 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
// [READ] These three lines are used to import the package 'express', create an app using it and also defining a port on which the server will run
const express = require('express');
const app = express();
const port = 8000;
const cors = require('cors');
app.use(cors());
// [TODO 4] setup the connection with db by requiring it from config/mongoose.js
// [TODO 2] install ejs and set the template engine
// [READ] This helps in parsing data which is submitted from a form in html
app.use(express.urlencoded({ extended: false}));
// [ASSIGNMENT] add middleware to use static files
// [TODO 1] add middleware to use the router by requiring it from routes/index.js
// [READ] Here we are asking our app to listen on the port defined at the top, this will run the express server which will communicate via port defined as above (initially 8000)
app.listen(port, function(err){
if (err){
console.log('Error in running server');
return;
}
console.log('Server is up and running on http://localhost:' + port);
});