Доработки контроллера
This commit is contained in:
@@ -3,9 +3,14 @@ const BaseController = require('./BaseController');
|
|||||||
const Lazy = require('lazy.js');
|
const Lazy = require('lazy.js');
|
||||||
|
|
||||||
class MiscController extends BaseController {
|
class MiscController extends BaseController {
|
||||||
async configValue(req) {
|
async getConfig(req, res) {
|
||||||
return Lazy(this.config).pick([req.params.name]).toObject();
|
if (Array.isArray(req.body.params))
|
||||||
|
return Lazy(this.config).pick(req.body.params).toObject();
|
||||||
|
//bad request
|
||||||
|
res.status(400).send({error: 'params is not an array'});
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MiscController;
|
module.exports = MiscController;
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ function initRoutes(app, connPool, config) {
|
|||||||
const misc = new c.MiscController(connPool, config);
|
const misc = new c.MiscController(connPool, config);
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
['POST', '/api/config/:name', misc, 'configValue', {}],
|
['POST', '/api/config', misc, 'getConfig', {}],
|
||||||
|
|
||||||
['GET', '/api/config/:name', misc, 'configValue', {}],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (route of routes) {
|
for (route of routes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user