dashboard-core/theme/dbd-soft-ui/pages/post/logs.js
Jonny_Bro (Nikita) 08275381dc integrate theme
2023-06-19 14:21:58 +05:00

23 lines
No EOL
598 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' })
}
}