Add debug route to delete the database
To simplify development add a debug route to delete the database content so that it'll be re-generated to the demo schedule.
This commit is contained in:
parent
25793fecb8
commit
16191a8dd2
2 changed files with 38 additions and 1 deletions
20
server/api/admin/delete-database.post.ts
Normal file
20
server/api/admin/delete-database.post.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { deleteDatbase, readAccounts } from "~/server/database";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await requireAccountSession(event);
|
||||
let accounts = await readAccounts();
|
||||
const sessionAccount = accounts.find(
|
||||
account => account.id === session.accountId
|
||||
);
|
||||
if (!sessionAccount) {
|
||||
throw Error("Account does not exist");
|
||||
}
|
||||
if (sessionAccount.type !== "admin") {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Forbidden",
|
||||
});
|
||||
}
|
||||
|
||||
await deleteDatbase();
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue