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}"