forked from microsoft/ContosoAir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
36 lines (32 loc) · 1.13 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 path = require('path');
const logger = require('morgan');
const Handlebars = require('handlebars');
const exphbs = require('express-handlebars');
const session = require("express-session");
const flash = require('express-flash');
const favicon = require('serve-favicon');
const passport = require('./src/config/passport.config');
const configureI18N = require('./src/config/i18n.config');
const i18n = configureI18N(__dirname);
const app = express();
app.use(logger('dev'));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(flash());
app.use(session({ secret: 'secret', resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session());
app.use(i18n.init);
app.engine('hbs', exphbs({
extname: '.hbs',
defaultLayout: 'main',
helpers: {
i18n: (s, req) => new Handlebars.SafeString(req.data.root.__(s))
}
}));
app.set('view engine', 'hbs');
app.use(favicon(__dirname + '/public/assets/favicon.ico'));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', require('./src/routes'));
module.exports = app;