feat: add env variables for port, database url and data dir

This commit is contained in:
Elias Schneider
2023-05-05 11:37:02 +02:00
parent 5132d177b8
commit 98c0de78e8
11 changed files with 43 additions and 26 deletions

2
backend/prisma/.env Normal file
View File

@@ -0,0 +1,2 @@
#This file is only used to set a default value for the database url
DATABASE_URL="file:../data/pingvin-share.db"

View File

@@ -4,7 +4,7 @@ generator client {
datasource db {
provider = "sqlite"
url = "file:../data/pingvin-share.db"
url = env("DATABASE_URL")
}
model User {

View File

@@ -1,6 +1,5 @@
import { Prisma, PrismaClient } from "@prisma/client";
import * as crypto from "crypto";
const configVariables: ConfigVariables = {
internal: {
jwtSecret: {
@@ -162,7 +161,15 @@ type ConfigVariables = {
};
};
const prisma = new PrismaClient();
const prisma = new PrismaClient({
datasources: {
db: {
url:
process.env.DATABASE_URL ||
"file:../data/pingvin-share.db?connection_limit=1",
},
},
});
async function seedConfigVariables() {
for (const [category, configVariablesOfCategory] of Object.entries(