owltide/server/api/admin/database-export.post.ts

16 lines
624 B
TypeScript
Raw Normal View History

import { readNextSessionId, readNextUserId, readSchedule, readSessions, readSubscriptions, readUsers } from "~/server/database";
export default defineEventHandler(async (event) => {
await requireServerSessionWithAdmin(event);
setHeader(event, "Content-Disposition", 'attachment; filename="database-dump.json"');
setHeader(event, "Content-Type", "application/json; charset=utf-8");
return {
nextUserId: await readNextUserId(),
users: await readUsers(),
nextSessionId: await readNextSessionId(),
sessions: await readSessions(),
subscriptions: await readSubscriptions(),
schedule: await readSchedule(),
};
})