mirror of
https://github.com/detleph/server.git
synced 2026-09-07 07:56:18 +02:00
Add code that ensures that an (admin) user is always present
This commit is contained in:
@@ -2,12 +2,20 @@ import express from "express";
|
|||||||
import prisma from "./lib/prisma";
|
import prisma from "./lib/prisma";
|
||||||
import eventRouter from "./Routes/event.routes";
|
import eventRouter from "./Routes/event.routes";
|
||||||
import adminAuthRouter from "./Routes/admin_auth.routes";
|
import adminAuthRouter from "./Routes/admin_auth.routes";
|
||||||
|
import argon2 from "argon2";
|
||||||
|
|
||||||
require("dotenv").config(); // Load dotenv config
|
require("dotenv").config(); // Load dotenv config
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
async function main() {
|
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
|
// Todo: Everything
|
||||||
|
|
||||||
// Bodyparser and urlencoded to parse post request bodies
|
// Bodyparser and urlencoded to parse post request bodies
|
||||||
|
|||||||
Reference in New Issue
Block a user