From 99d55d2fbcad1e04b0a0b672913584ccf198e70a Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Fri, 22 Feb 2019 02:18:37 +0000 Subject: [router] All modules have the new api style, deleted old unnecessary code --- server/router.js | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'server/router.js') diff --git a/server/router.js b/server/router.js index b00f164..4aa7e54 100644 --- a/server/router.js +++ b/server/router.js @@ -14,30 +14,6 @@ fs.readdirSync(path.join(__dirname, 'api')).forEach(filename => { if (api.router) router.use('/' + filename.split('.')[0] + '/', auth.verifyToken, permUtil.exportFunctions, api.router) }) -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// !!!!!!!! TODO: DELETE IF ALL MODULES ARE REWORKED WITH exports.router !!!!!!! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -// Dynamic API routes -function mapApi (method) { - return function (req, res) { - var api = require(path.join(__dirname, 'api', req.params.api)) - if (method in api && req.params.action in api[method]) { - api[method][req.params.action](req, res) - } else { - res.status(501).end() - } - } -} - -// Every API can be called with // -router.get('/:api/:action', auth.verifyToken, mapApi('get')) -router.post('/:api/:action', auth.verifyToken, mapApi('post')) - -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - router.use('*', (req, res) => { res.status(404).end() }) -- cgit v1.2.3-55-g7522