AppReports/lib/api/get-log.js

30 lines
808 B
JavaScript
Raw Normal View History

2020-08-19 12:33:09 +02:00
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of appreports which is released under GPL-3.0-or-later.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
2020-07-29 20:56:03 +02:00
'use strict';
const db = require ('../db');
const { http } = require ('@sapphirecode/consts');
module.exports = async (req, res) => {
const limit = parseInt (req.headers.limit);
const offset = parseInt (req.headers.offset);
const app_id = parseInt (req.headers.app_id);
if (isNaN (app_id)) {
2020-08-16 11:48:06 +02:00
res.status (http.status_bad_request)
.end ('app id not specified');
2020-08-16 11:48:06 +02:00
}
res.status (http.status_ok)
.json (await db.log.get_all (
parseInt (req.headers.app_id),
isNaN (limit) ? 100 : limit,
isNaN (offset) ? 0 : offset
));
2020-07-29 20:56:03 +02:00
};