-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (22 loc) · 720 Bytes
/
app.js
File metadata and controls
30 lines (22 loc) · 720 Bytes
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
const path = require('path');
const express = require('express');
const exphbs = require('express-handlebars')
const bodyParser = require('body-parser');
const routes = require('./routes/index');
const app = express();
const dotenv = require('dotenv')
dotenv.load()
// view engine setup
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
// catch 404 and display error
app.use('*', function(req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
module.exports = app;