main.js 952 Bytes
const fs = require('fs');
const path = require('path');
const express = require('express');
const exphbs = require('express-handlebars');
const app = require('./server');

const hbs = exphbs.create({
    helpers: {
        dateFormat(d) {
            d = new Date(d);
            return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()} ${d.getHours()}:${d.getMinutes()}`;
        },
        dateFromObjectId(o) {
            o = new Date(parseInt(o.toString().substring(0, 8), 16) * 1000);
            return `${o.getFullYear()}-${o.getMonth()}-${o.getDate()} ${o.getHours()}:${o.getMinutes()}`;
        }
    }
});
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
app.set('views', path.join(__dirname, 'views'));

fs.readdirSync(path.resolve(__dirname, 'routes')).forEach((name) => {
    require(path.resolve(__dirname, 'routes', name));
});

app.use(express.static(path.resolve(__dirname, 'public')));

app.listen(3429);