2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var express = require('express');
18 var session = require('express-session');
19 var path = require('path');
20 var bodyParser = require('body-parser');
21 var JL = require('jsnlog').JL;
22 var jsnlog_nodejs = require('jsnlog-nodejs').jsnlog_nodejs;
23 var logger = JL('app.js');
24 var AppConfig = require('./config.json');
29 app.set('port', process.env.PORT || AppConfig.TIC_WEB.PORT);
30 app.use(bodyParser.json());
31 app.use(bodyParser.urlencoded({extended: true}));
32 app.use(express.static(path.join(__dirname, '/public/src'))); //module directory
34 var server = require('./controller/server').start(app);
35 var io = require('./controller/socketio').listen(server);
36 var router = require('./controller/router').init(server);
41 saveUninitialized: true
44 app.use('/api', router);
47 * jsnlog.js on the client by default sends log messages to /jsnlog.logger, using POST.
51 app.post('*.logger', function (req, res) {
52 // Pass the log messages to the server side jsnlog.js
53 jsnlog_nodejs(JL, req.body);
55 // Send empty response. This is ok, because client side jsnlog does not use response from server.