dashboard-core/theme/dbd-soft-ui/pages/post/logs.js

21 lines
498 B
JavaScript
Raw Normal View History

2023-06-19 14:21:58 +05:00
module.exports = {
2023-06-22 19:36:52 +05:00
page: "/stats/logs/update",
execute: async (req, res, app, config, themeConfig, info, db) => {
if ("Bearer " + themeConfig.admin?.logs?.key !== req.headers.authorization) return res.json({ status: "Invalid sharding key" });
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
const logs = await db.get("logs");
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
let newLogs = [];
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
if (!logs || !logs.length || !logs[0])
newLogs = [req.body];
else
newLogs = [req.body, ...logs];
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
await db.set("logs", newLogs);
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
res.json({
status: "Completed",
});
},
};