Add routes and admin panel elements for creating a database backup, restoring from a backup, deleting the existing schedule, and replacing the database with the demo schedule. These server as crude ways to manage the data stored in the system.
15 lines
624 B
TypeScript
15 lines
624 B
TypeScript
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(),
|
|
};
|
|
})
|