-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (24 loc) · 812 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
30
31
32
33
34
// import and initiate express
const express = require('express');
const app = express();
// import dotenv
require('dotenv').config();
// import middleware
const errorMiddleware = require('./middlewares/error');
const notFoundMiddleware = require('./middlewares/notfound');
// applying static middlewares
app.use(express.static('public'));
// applying body reader middlewares
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// import router
const router = require('./router.js');
// applying ejs view engine
app.set('view engine', 'ejs');
app.listen(process.env.PORT, () => {
console.log(`Server successfully now running on PORT ${process.env.PORT}`);
});
app.use(router);
// applying error & not found middleware
app.use(errorMiddleware);
app.use(notFoundMiddleware);