Add code that ensures that an (admin) user is always present

This commit is contained in:
Stephan
2022-04-28 12:49:07 +02:00
committed by Stefan-5422
parent dd3133c3f3
commit c0878d5614
+8
View File
@@ -2,12 +2,20 @@ import express from "express";
import prisma from "./lib/prisma";
import eventRouter from "./Routes/event.routes";
import adminAuthRouter from "./Routes/admin_auth.routes";
import argon2 from "argon2";
require("dotenv").config(); // Load dotenv config
const app = express();
async function main() {
// Dev
await prisma.admin.upsert({
where: { id: 1 },
create: { name: "admin", password: await argon2.hash("test", { type: argon2.argon2id }) },
update: {},
});
// Todo: Everything
// Bodyparser and urlencoded to parse post request bodies