🛂 Add script for creating an initial admin key
This commit is contained in:
12
README.md
12
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)
|
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
|
## 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)
|
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
|
npm install
|
||||||
node index.js
|
node index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to create an admin key, you can again use the `createAdminKey.js` script
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node createAdminKey.js
|
||||||
|
```
|
||||||
|
13
server/createAdminKey.js
Normal file
13
server/createAdminKey.js
Normal file
@ -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);
|
||||||
|
})();
|
Reference in New Issue
Block a user