-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (25 loc) · 891 Bytes
/
server.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
/*jshint esversion: 8 */
const express = require('express');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const PORT = process.env.PORT || 3000;
const app = express();
// Serve static content for the app from the 'public' directory
app.use(express.static(process.cwd() + '/public'));
app.use(bodyParser.urlencoded({
extended: false
}));
// Override with POST having ?_method=DELETE
app.use(methodOverride('_method'));
// Set Handlebars as the view engine
const exphbs = require('express-handlebars');
app.engine('handlebars', exphbs({
defaultLayout: 'main'
}));
app.set('view engine', 'handlebars');
// Import routes and give the server access to them.
const routes = require("./controllers/burgersController.js");
app.use(routes);
app.listen(PORT, function() {
console.log("App now listening at localhost:" + PORT);
});