Implement database administration
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.
This commit is contained in:
parent
b2f48e98e0
commit
e5e923bc8d
6 changed files with 190 additions and 5 deletions
15
server/api/admin/database-export.post.ts
Normal file
15
server/api/admin/database-export.post.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
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(),
|
||||
};
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue