-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (33 loc) · 1.01 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
// importing packages
const express = require('express');
const port = 3000;
const app = express();
const path = require('path');
const expressLayouts = require('express-ejs-layouts');
const csv = require('csv-parser');
const db = require("./config/mongoose");
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser')
require('dotenv').config();
app.use(cookieParser())
var userRoute = require('./routes/userRoute')
// setting layouts
app.use(expressLayouts);
// middleware for body-parser
app.use(bodyParser.json());
app.use(express.urlencoded({extended: true}));
//accesing static files from assets folder
app.use(express.static('./assets'));
//setting up view engine
app.set("view engine", "ejs");
app.set("views", "./views");
// setting up routes
app.use('/', userRoute)
// directing the app in the given port
app.listen(port, function(err) {
if(err) {
console.log('Error', err);
return;
}
console.log('Server is up and running on port: ', port);
});