Add better error codes
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
1064db3d2f
commit
dd96e95ce5
@ -1,3 +1,4 @@
|
||||
# What to do next:
|
||||
|
||||
* Rewrite sanitizing functions to remove external dependancy.
|
||||
* Rewrite sanitizing functions to remove external dependancy.
|
||||
* Change /api/v1/auth endpoints to /api/v1/register endpoints - auth is done in middleware
|
@ -23,6 +23,7 @@ async function getTime(req, res, next){
|
||||
res.json(await kube.getTime(req.body))
|
||||
} catch (err) {
|
||||
console.error(`Unknown Error`, err.message);
|
||||
err.status = 503
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ async function get(req, res, next){
|
||||
res.json(await ldb.get(req.body, id))
|
||||
} catch (err) {
|
||||
console.error(`Unknown Error`, err.message);
|
||||
err.status = 500
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ async function getStations(req, res, next){
|
||||
res.json(await list.getStations(req.body))
|
||||
} catch (err) {
|
||||
console.error(`Controller Error`, err.message);
|
||||
err.status = 500
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
@ -14,6 +15,7 @@ async function getCorpus(req, res, next){
|
||||
res.json(await list.getCorpus(req.body))
|
||||
} catch (err) {
|
||||
console.error(`Controller Error`, err.message);
|
||||
err.status = 500
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
@ -23,6 +25,7 @@ async function hits(req, res, next) {
|
||||
res.json(await list.hits())
|
||||
} catch (err) {
|
||||
console.error(`Controller Error`, err);
|
||||
err.status = 500
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ async function get(req, res, next) {
|
||||
res.json(await stat.hits())
|
||||
} catch (err) {
|
||||
console.error(`Controller Error`, err);
|
||||
err.status = 500
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get}
|
||||
get
|
||||
}
|
19
src/routes/ldbs.routes.js
Normal file
19
src/routes/ldbs.routes.js
Normal file
@ -0,0 +1,19 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const ldbController = require('../controllers/ldb.controllers');
|
||||
|
||||
/* GET programming languages. */
|
||||
//router.get('/', programmingLanguagesController.get);
|
||||
|
||||
/* POST programming language */
|
||||
//router.post('/', programmingLanguagesController.create);
|
||||
|
||||
/* PUT programming language */
|
||||
//router.put('/:id', programmingLanguagesController.update);
|
||||
|
||||
/* DELETE programming language */
|
||||
//router.delete('/:id', programmingLanguagesController.remove);
|
||||
|
||||
router.get('/:id', ldbController.get);
|
||||
|
||||
module.exports = router;
|
Loading…
Reference in New Issue
Block a user