forked from origo-map/origo-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (28 loc) · 1.09 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
37
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var mapStateRouter = require('./routes/mapstate');
var errors = require('./routes/errors');
var app = express();
var server = app.listen(3001, function () {
var host = server.address().address
var port = server.address().port
console.log('Origo server listening at http://%s:%s', host, port)
});
//Workaround to set __dirname properly when using node-windows
process.chdir(__dirname);
var handlebars = require('express-handlebars')
.create({defaultLayout: 'main'});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.set('views', path.join(__dirname, 'views'));
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/origoserver/', routes);
app.use('/mapstate', mapStateRouter);
app.use(errors);
module.exports = app;