-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (29 loc) · 900 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
'use strict';
const express = require('express');
const logger = require('./utils/logger');
const bodyParser = require('body-parser');
var assets = require("./assets");
const app = express();
app.use("/assets", assets);
const exphbs = require('express-handlebars');
app.use(bodyParser.urlencoded({ extended: false, }));
app.use(express.static('public'));
app.engine('.hbs', exphbs({
extname: '.hbs',
defaultLayout: 'main',
helpers: {
CalculateDuration: function (songs) {
let total=0;
for (let i in songs) {
total+=songs[i].duration;
}
return total + ' mins';
}
}
}));
app.set('view engine', '.hbs');
const routes = require('./routes');
app.use('/', routes);
const listener = app.listen(process.env.PORT || 4000, function () {
logger.info(`gomix-template-1 started on port ${listener.address().port}`);
});