-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (25 loc) · 895 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
34
35
36
'use strict';
const express = require('express');
const logger = require('./utils/logger');
const bodyParser = require('body-parser');
const auth = require('http-auth');
var basic = auth.basic({
realm: 'SUPER SECRET STUFF'
}, function(username, password, callback) {
callback(username == process.env.USER && password == process.env.SECRET);
});
var app = express();
var authMiddleware = auth.connect(basic);
const exphbs = require('express-handlebars');
app.use(bodyParser.urlencoded({ extended: false, }));
app.use(express.static('public'));
app.engine('.hbs', exphbs({
extname: '.hbs',
defaultLayout: 'main',
}));
app.set('view engine', '.hbs');
const routes = require('./routes');
app.use('/', authMiddleware, routes);
const listener = app.listen(process.env.PORT || 4000, function () {
logger.info(`gomix-template-1 started on port ${listener.address().port}`);
});