mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add admin utils
This commit is contained in:
15
dashboard/server/api/admin/reset_count.ts
Normal file
15
dashboard/server/api/admin/reset_count.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import { ProjectCountModel } from "@schema/ProjectsCounts";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const { project_id } = getQuery(event);
|
||||
if (!project_id) return setResponseStatus(event, 400, 'ProjectId is required');
|
||||
|
||||
await ProjectCountModel.updateOne({ project_id, events: 0, visits: 0 }, {}, { upsert: true });
|
||||
|
||||
return { ok: true };
|
||||
});
|
||||
Reference in New Issue
Block a user