-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
58 lines (46 loc) · 1.57 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { envPort } = require('./config.js');
const express = require('express');
const hbs = require('hbs');
const path = require('path');
const bodyParser = require('body-parser');
const routes = require('./routes/routes.js');
const db = require('./models/db.js');
const app = express();
const port = envPort;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true,
parameterLimit: 100000,
limit: '50mb',
}));
app.set('view engine', 'hbs');
app.use(express.static('public'));
app.use(express.static('views'));
app.use(express.static('uploads'));
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')));
hbs.registerPartials(__dirname + '/views/partials');
app.use('/', routes);
db.connect();
app.listen(port, function() {
console.log('App listening at port ' + port)
});
hbs.registerHelper('dateFormat', require('handlebars-dateformat'));
hbs.registerHelper('repeat', require('handlebars-helper-repeat'));
hbs.registerHelper("add", function (a, b) {
return parseInt(a) + b;
});
hbs.registerHelper("minus", function (a, b) {
return parseInt(a) - b;
});
hbs.registerHelper('equals', function (arg1, arg2, options) {
return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
});
hbs.registerHelper('each_upto', function (ary, max, options) {
if (!ary || ary.length == 0)
return options.inverse(this);
var result = [];
for (var i = 0; i < max && i < ary.length; ++i)
result.push(options.fn(ary[i]));
return result.join('');
});