Add endpoints /api/get_websocket_config and /api/get_glass_config

This commit is contained in:
Akkadius 2018-08-13 23:53:56 -05:00
parent 858806c5b7
commit 29fd1d7591
3 changed files with 49 additions and 0 deletions

20
api/get_glass_config.js Normal file
View File

@ -0,0 +1,20 @@
/**
* Created by cmiles on 8/13/2018.
*/
var express = require('express');
var router = express.Router();
var authorize = require('../lib/authorize.js');
router.get('/', authorize.auth, function (req, res, next) {
var json_file = require('jsonfile');
var glass_config = json_file.readFileSync('config/glass_config.json');
/**
* Return response
*/
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(glass_config));
});
module.exports = router;

View File

@ -0,0 +1,27 @@
/**
* Created by cmiles on 8/13/2018.
*/
var express = require('express');
var router = express.Router();
router.get('/', function (req, res, next) {
var json_file = require('jsonfile');
var glass_config = json_file.readFileSync('config/glass_config.json');
/**
* Config structure
*
* @type {{}}
*/
let websocket_config = {};
websocket_config.ws_port = glass_config.ws_port;
/**
* Return response
*/
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(websocket_config));
});
module.exports = router;

2
app.js
View File

@ -54,6 +54,8 @@ app.use('/api/get_mac_oui_count_by_vendor/', require('./api/get_mac_oui_count_by
app.use('/api/get_dhcp_requests/', require('./api/get_dhcp_requests'));
app.use('/api/get_server_info/', require('./api/get_server_info'));
app.use('/api/get_mac_oui_list/', require('./api/get_mac_oui_list'));
app.use('/api/get_glass_config/', require('./api/get_glass_config'));
app.use('/api/get_websocket_config/', require('./api/get_websocket_config'));
app.set('view engine', 'html');