diff --git a/README.md b/README.md index cb8ae80..035b0bd 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ docker-compose logs -f If everything is working, you should be able to connect to the app at http://localhost:3000 (or the IP address of your docker host) +To create an admin key for managing timetables or creating keys, you can use the `createAdminKey.js` script + +```sh +docker compose exec app node /app/server/createAdminKey.js +``` + ## Setup for Development To setup a development environment for Timetable V2, you will need to have NodeJS and Docker installed. (If you don't want to install Docker, you can also install PostgreSQL natively on your computer) @@ -86,3 +92,9 @@ Now you just need to install the dependencies and are ready to run the app: npm install node index.js ``` + +If you want to create an admin key, you can again use the `createAdminKey.js` script + +```sh +node createAdminKey.js +``` diff --git a/server/createAdminKey.js b/server/createAdminKey.js new file mode 100644 index 0000000..24d7ab6 --- /dev/null +++ b/server/createAdminKey.js @@ -0,0 +1,13 @@ +import Prisma from "@prisma/client"; + +const prisma = new Prisma.PrismaClient(); +(async () => { + const key = await prisma.key.create({ + data: { + permissions: ["admin"], + notes: `Created at ${new Date().toLocaleString()} using the "createAdminKeys.js" script`, + }, + }); + console.log("Created admin key:"); + console.log(key.key); +})();