-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
36 lines (28 loc) · 1.04 KB
/
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
const express = require('express');
const bodyParser = require('body-parser');
const exphbs = require('express-handlebars');
const configRoutes = require('./routes');
const st = express.static(__dirname + '/public');
const app = express();
app.use('/public', st);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const handlebarsInstance = exphbs.create({
defaultLayout: "main",
// Specify helpers which are only registered on this instance.
helpers: {
asJSON: (obj, spacing) => {
if (typeof spacing === "number")
return new Handlebars.SafeString(JSON.stringify(obj, null, spacing));
return new Handlebars.SafeString(JSON.stringify(obj));
}
},
partialsDir: ["views/partials/"]
});
app.engine("handlebars", handlebarsInstance.engine);
app.set('view engine', 'handlebars');
configRoutes(app);
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
if (process && process.send) process.send({done: true}); // ADD THIS LINE
});