2014-12-22 22:43:57 -06:00
|
|
|
/* jshint -W079 */
|
|
|
|
(function() {
|
|
|
|
var scribe = require('../scribe')(),
|
|
|
|
console = process.console,
|
|
|
|
express = require('express'),
|
2014-12-23 05:12:03 -06:00
|
|
|
path = require('path'),
|
2014-12-22 22:43:57 -06:00
|
|
|
app = express();
|
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
console.addLogger('log', 'green');
|
2014-12-22 22:43:57 -06:00
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
// port
|
2014-12-22 22:43:57 -06:00
|
|
|
app.set('port', (process.env.PORT || 5000));
|
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
// public dir
|
|
|
|
app.use('/', express.static(path.join(__dirname, 'public')));
|
|
|
|
|
|
|
|
// scribe
|
|
|
|
app.use(scribe.express.logger());
|
|
|
|
app.use('/logs', scribe.webPanel());
|
|
|
|
|
|
|
|
// index
|
2014-12-22 22:43:57 -06:00
|
|
|
app.get('/', function(req, res) {
|
2014-12-23 05:12:03 -06:00
|
|
|
res.sendFile(path.join(__dirname, 'views', 'index.html'));
|
2014-12-22 22:43:57 -06:00
|
|
|
});
|
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
// log
|
|
|
|
app.post('/', function(req, res){
|
|
|
|
var data = req.param('data');
|
2014-12-22 22:43:57 -06:00
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
if(typeof data === 'undefined'){
|
|
|
|
return res.status(400).send('`data` param not defined');
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
} catch(e){
|
|
|
|
// ignore
|
|
|
|
}
|
2014-12-22 22:43:57 -06:00
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
// print
|
|
|
|
console.log(data);
|
2014-12-22 22:43:57 -06:00
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
res.status(200);
|
2014-12-22 22:43:57 -06:00
|
|
|
});
|
|
|
|
|
2014-12-23 05:12:03 -06:00
|
|
|
var port = app.get('port');
|
2014-12-22 22:43:57 -06:00
|
|
|
|
|
|
|
app.listen(port, function() {
|
|
|
|
console.time().log('Server listening at port ' + port);
|
|
|
|
});
|
|
|
|
})();
|