From 7f235e97a814a99a2e09912dc92793c023ee0e89 Mon Sep 17 00:00:00 2001 From: Kai Ritthaler Date: Sun, 18 May 2025 19:36:42 +0200 Subject: [PATCH] added some comments --- code/backend/.env.example | 1 + code/backend/scripts/install.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/backend/.env.example b/code/backend/.env.example index 54cc487..c0966a2 100644 --- a/code/backend/.env.example +++ b/code/backend/.env.example @@ -1,3 +1,4 @@ +# This is an example of a .env file. You don`t need it unless you fuck up the .env file generated by the install script DATABASE_URL="postgres://postgres:YourPassword@localhost:5432/prisma" TOKEN_SECRET=ThisIsVeryImportantChangeThisToSomethingSecureThisIsUsedToEncryptTheJWT DB_USER=postgres diff --git a/code/backend/scripts/install.ts b/code/backend/scripts/install.ts index 39f6e28..fbcb01b 100644 --- a/code/backend/scripts/install.ts +++ b/code/backend/scripts/install.ts @@ -1,18 +1,17 @@ +// this script is used to install the project import { exec } from "child_process"; import util from "util"; const execPromise = util.promisify(exec); import fs, { read } from "fs"; import readlineSync from "readline-sync"; import crypto from "crypto"; -import dotenv from "dotenv" -import path from "path"; const json_path: string = "scripts/install.json"; // Path to the JSON file const raw = fs.readFileSync(json_path, "utf8"); const config = JSON.parse(raw); // Parse the JSON file //check if there is a .env file and abort the installation -if (fs.existsSync(".env") ) { +if (fs.existsSync(".env")) { // Check if the script has already been run console.log("Already installed"); process.exit(0); @@ -30,7 +29,7 @@ while (!postgresPassword) { }); !postgresPassword && console.log("Password cannot be empty"); } -// getting user input for .env file +// generating a random JWT secret const jwtSecret: string = crypto.randomBytes(32).toString("hex"); // 64 Zeichen const env: string = `DATABASE_URL="postgresql://${postgresUser}:${postgresPassword}@localhost:5432/prisma" TOKEN_SECRET="${jwtSecret}"