-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
39 lines (30 loc) · 941 Bytes
/
app.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
// libraries
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
// middlewares/
const errorHandling = require('./middlewares/errorHandling');
const auth = require('./middlewares/auth');
// router
const router = require('./router/indexRouter');
// app creation
const app = express();
// using libraries
// app.use(fileUpload({ createParentPath : true }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(auth);
app.use(morgan('tiny'));
// setting ejs to be view engine
app.set('view engine', 'ejs');
// allow public directory
app.use(express.static('public'))
//app.set('strict routing', true);
// using router
app.use('/', router);
// using error handling middlware
app.use(errorHandling.notFound);
app.use(errorHandling.errorHandler);
module.exports = app;