-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
40 lines (29 loc) · 846 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
35
36
37
38
39
40
/**
* @file Bootstrap express.js server
*/
const express = require("express");
const morgan = require("morgan");
const path = require("path");
const cors = require("cors");
const router = require("../config/routes");
const publicDir = path.join(__dirname, "../public");
const viewsDir = path.join(__dirname, "./views");
const app = express();
/* .env variables */
require("dotenv").config();
/* Middlewares cors */
app.use(cors());
/** Install request logger */
app.use(morgan("dev"));
/** Install body parser */
app.use(express.urlencoded({ extended: true }));
/** Install JSON request parser */
app.use(express.json());
/** Install View Engine */
app.set("views", viewsDir);
app.set("view engine", "ejs");
/** Set Public Directory */
app.use(express.static(publicDir));
/** Install Router */
app.use(router);
module.exports = app;