split per app

This commit is contained in:
2020-08-16 11:48:06 +02:00
parent d3a19c953a
commit c5be16963d
12 changed files with 126 additions and 14 deletions

10
lib/api/get-app.js Normal file
View File

@ -0,0 +1,10 @@
'use strict';
const db = require ('../db');
const { http } = require ('@sapphirecode/consts');
module.exports = async (req, res) => {
const apps = await db.app.get_all ();
res.status (http.status_ok)
.json (apps);
};

View File

@ -4,6 +4,15 @@ const db = require ('../db');
const { http } = require ('@sapphirecode/consts');
module.exports = async (req, res) => {
res.status (http.status_ok)
.json (await db.get_all ());
if (
typeof req.headers.app_id === 'undefined'
|| isNaN (parseInt (req.headers.app_id))
) {
res.status (http.status_bad_request)
.end ();
}
else {
res.status (http.status_ok)
.json (await db.log.get_all (parseInt (req.headers.app_id)));
}
};

View File

@ -4,5 +4,6 @@ const router = require ('express')
.Router ();
router.get ('/log', require ('./get-log'));
router.get ('/app', require ('./get-app'));
module.exports = router;