1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-29 12:42:16 -05:00
kaiwa/server.js

67 lines
1.9 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',
templateFile: __dirname + '/clientapp/template.html',
2013-09-27 03:27:35 -04:00
developmentMode: config.isDev,
2013-06-03 18:51:30 -04:00
libraries: [
2013-08-30 01:37:24 -04:00
__dirname + '/clientapp/libraries/zepto.js',
2013-09-12 14:18:44 -04:00
__dirname + '/clientapp/libraries/ui.js',
2013-09-18 19:24:40 -04:00
__dirname + '/clientapp/libraries/resampler.js',
2013-09-27 01:52:54 -04:00
__dirname + '/clientapp/libraries/IndexedDBShim.min.js'
2013-08-29 23:38:28 -04:00
],
stylesheets: [
2013-09-16 05:19:07 -04:00
__dirname + '/public/css/otalk.css'
2013-06-03 18:51:30 -04:00
],
2013-08-29 23:38:28 -04:00
server: app,
beforeBuild: function () {
2013-09-20 16:45:24 -04:00
if (config.isDev) {
var clientFolder = __dirname + '/clientapp';
templatizer(clientFolder + '/templates', clientFolder + '/templates.js');
}
2013-08-29 23:38:28 -04:00
}
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');
});
app.get('/oauth/login', function (req, res) {
res.redirect('https://apps.andyet.com/oauth/authorize?client_id=' + config.andyetAuth.id + '&response_type=token');
});
app.get('/oauth/callback', function (req, res) {
res.render('oauthLogin');
});
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
//https.createServer({
// key: fs.readFileSync(config.http.key),
// cert: fs.readFileSync(config.http.cert)
//}, app).listen(config.http.port);
app.listen(config.http.port);
2013-08-20 13:45:06 -04:00
console.log('demo.stanza.io running at: ' + config.http.baseUrl);