2018-11-02 15:24:39 -04:00
|
|
|
/*jshint esversion: 6 */
|
|
|
|
const path = require('path');
|
|
|
|
const express = require('express');
|
|
|
|
const app = express();
|
2022-04-17 10:12:50 -04:00
|
|
|
const expressWs = require('express-ws')(app);
|
2018-11-02 15:24:39 -04:00
|
|
|
const cors = require('cors');
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
const errorhandler = require(path.resolve( __dirname, 'app/_helpers/error-handler.js'));
|
|
|
|
const compression = require('compression');
|
|
|
|
|
|
|
|
app.use(compression());
|
|
|
|
app.use(bodyParser.urlencoded({extended: true}));
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(cors());
|
|
|
|
|
|
|
|
app.use(express.static(__dirname + '/pub'));
|
|
|
|
app.get('/', (req, res) => {
|
2022-04-17 10:12:50 -04:00
|
|
|
res.sendFile(path.resolve(__dirname + '/pub/index.html'));
|
2018-11-02 15:24:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
app.use('/camera', require(path.resolve( __dirname, 'app/camera/camera.controller.js')));
|
|
|
|
app.use('/ptz', require(path.resolve( __dirname, 'app/ptz/ptz.controller.js')));
|
|
|
|
app.use('/image', require(path.resolve( __dirname, 'app/image/image.controller.js')));
|
2022-04-17 10:12:50 -04:00
|
|
|
app.use('/stream', require(path.resolve( __dirname, 'app/stream/stream.controller.js')));
|
2018-11-02 15:24:39 -04:00
|
|
|
app.get('*', function(req, res){
|
2022-04-17 10:12:50 -04:00
|
|
|
res.status(404).send('404 not found');
|
2018-11-02 15:24:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
app.use(errorhandler);
|
|
|
|
|
|
|
|
const port = process.env.NODE_ENV === 'production' ? 80 : 4000;
|
|
|
|
const server = app.listen(port, function() {
|
2022-04-17 10:12:50 -04:00
|
|
|
console.log('Server listening on port ' + port);
|
2018-11-02 15:24:39 -04:00
|
|
|
});
|