[TIC-Web] sets the format of a directory listing
[archive/20170607/tools/tic.git] / app.js
1 var express = require('express');
2 var app = express();
3 var path = require('path');
4 var bodyParser = require('body-parser');
5 var JL = require('jsnlog').JL;
6 var jsnlog_nodejs = require('jsnlog-nodejs').jsnlog_nodejs;
7 var logger = JL('app.js');
8 var config = require('./config.json');
9
10 /* app config */
11 app.set('port', process.env.PORT || config.TIC_WEB.PORT);
12 app.use(bodyParser.json());
13 app.use(bodyParser.urlencoded({extended: true}));
14 app.use(express.static(path.join(__dirname, '/public/src'))); //module directory
15
16 var server = require('./controller/server').start(app);
17 var io = require('./controller/socketio').listen(server);
18 var router = require('./controller/router').init(server);
19
20 app.use('/api', router);
21
22 /**
23  * jsnlog.js on the client by default sends log messages to /jsnlog.logger, using POST.
24  * @URI /*.logger
25  * @TYPE POST
26  */
27 app.post('*.logger', function (req, res) {
28     // Pass the log messages to the server side jsnlog.js
29     jsnlog_nodejs(JL, req.body);
30
31     // Send empty response. This is ok, because client side jsnlog does not use response from server.
32     res.send('');
33 });