dashboard-core/theme/dbd-soft-ui/pages/post/logs.js
Jonny_Bro (Nikita) 849a93887a
2023-06-22 19:36:52 +05:00

21 lines
No EOL
498 B
JavaScript

module.exports = {
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" });
const logs = await db.get("logs");
let newLogs = [];
if (!logs || !logs.length || !logs[0])
newLogs = [req.body];
else
newLogs = [req.body, ...logs];
await db.set("logs", newLogs);
res.json({
status: "Completed",
});
},
};