forked from derBroBro/terraform-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (33 loc) · 1 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
var express = require('express');
var passport = require('passport');
var exphbs = require('express-handlebars');
var bodyParser = require('body-parser');
var path = require('path');
var app_dir = path.dirname(require.main.filename);
var auth = require(app_dir+'/lib/auth/basic_local.js');
var logger = require(app_dir+'/lib/helper/logger.js');
var routes = require(app_dir+'/routes.js');
var config = require('./config.json');
logger.setup(config.system.log_level);
var app = express();
// Handlebars
app.engine('handlebars', exphbs({
defaultLayout: 'main',
helpers: {
toJSON: function(obj) {
return JSON.stringify(obj, null, 3);
}
}
}));
app.set('view engine', 'handlebars');
app.use(express.static('static'));
// body parser
app.use(bodyParser.urlencoded({ extended: false }));
// auth
auth.setup({users:config.system.users});
passport.use(auth.get());
// routes
routes.register(app);
app.listen(config.system.port, function() {
logger.info('Server listening on port '+config.system.port);
});