1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-11 20:15:00 -05:00
kaiwa/server.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-09-05 19:53:23 -04:00
var fs = require('fs');
var https = require('https');
2013-08-20 13:45:06 -04:00
var express = require('express');
2013-08-29 23:38:28 -04:00
var helmet = require('helmet');
2013-08-20 13:45:06 -04:00
var Moonboots = require('moonboots');
var config = require('getconfig');
2013-08-29 23:38:28 -04:00
var templatizer = require('templatizer');
2013-06-03 18:51:30 -04:00
2013-08-29 23:38:28 -04:00
var app = express();
app.use(express.compress());
2013-06-03 18:51:30 -04:00
app.use(express.static(__dirname + '/public'));
2013-08-29 23:38:28 -04:00
if (!config.isDev) {
app.use(helmet.xframe());
}
app.use(helmet.iexss());
app.use(helmet.contentTypeOptions());
2013-06-03 18:51:30 -04:00
var clientApp = new Moonboots({
2013-08-29 23:38:28 -04:00
main: __dirname + '/clientapp/app.js',
2013-06-03 18:51:30 -04:00
developmentMode: config.isDev,
libraries: [
2013-08-30 01:37:24 -04:00
__dirname + '/clientapp/libraries/zepto.js',
2013-08-29 23:38:28 -04:00
__dirname + '/clientapp/libraries/IndexedDBShim.min.js',
__dirname + '/clientapp/libraries/stanza.io.js'
],
stylesheets: [
__dirname + '/public/style.css'
2013-06-03 18:51:30 -04:00
],
2013-08-29 23:38:28 -04:00
browserify: {
debug: false
},
server: app,
beforeBuild: function () {
var clientFolder = __dirname + '/clientapp';
templatizer(clientFolder + '/templates', clientFolder + '/templates.js');
}
2013-06-03 18:51:30 -04:00
});
2013-09-05 19:53:23 -04:00
app.set('view engine', 'jade');
app.get('/login', function (req, res) {
res.render('login');
});
app.get('/logout', function (req, res) {
res.render('logout');
});
2013-08-29 23:38:28 -04:00
2013-06-03 18:51:30 -04:00
// serves app on every other url
app.get('*', clientApp.html());
2013-08-29 23:38:28 -04:00
2013-09-05 19:53:23 -04:00
https.createServer({
key: fs.readFileSync(config.http.key),
cert: fs.readFileSync(config.http.cert)
}, app).listen(config.http.port);
2013-08-20 13:45:06 -04:00
console.log('demo.stanza.io running at: ' + config.http.baseUrl);