diff --git a/.env.example b/.env.example index 30c166f..7d63ce3 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ DB_TYPE = (mysql|sqlite|...) +DB_PORT = number DB_HOST = database_host DB_NAME = database_name DB_USERNAME = database_username diff --git a/README.md b/README.md index e146e48..165f352 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ services: container_name: ff_member_administration_server restart: unless-stopped environment: - - DB_TYPE = mysql + - DB_TYPE=mysql - DB_HOST=ffm-db + - DB_PORT=number # fallback ist auf 3306 gesetzt - DB_NAME=administration - DB_USERNAME=administration_backend - DB_PASSWORD= diff --git a/src/data-source.ts b/src/data-source.ts index 7af52a0..6810a53 100644 --- a/src/data-source.ts +++ b/src/data-source.ts @@ -1,7 +1,7 @@ import "dotenv/config"; import "reflect-metadata"; import { DataSource } from "typeorm"; -import { DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_TYPE } from "./env.defaults"; +import { DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_TYPE, DB_PORT } from "./env.defaults"; import { user } from "./entity/user/user"; import { refresh } from "./entity/refresh"; @@ -70,7 +70,7 @@ import { ExtendViewValues1736084198860 } from "./migrations/1736084198860-extend const dataSource = new DataSource({ type: DB_TYPE as any, host: process.env.NODE_ENV || process.env.DBMODE ? "localhost" : DB_HOST, - port: 3306, + port: DB_PORT, username: DB_USERNAME, password: DB_PASSWORD, database: DB_NAME, diff --git a/src/env.defaults.ts b/src/env.defaults.ts index 21c9430..a662555 100644 --- a/src/env.defaults.ts +++ b/src/env.defaults.ts @@ -3,6 +3,7 @@ import ms from "ms"; export const DB_TYPE = process.env.DB_TYPE ?? "mysql"; export const DB_HOST = process.env.DB_HOST ?? ""; +export const DB_PORT = Number(process.env.DB_PORT ?? 3306); export const DB_NAME = process.env.DB_NAME ?? ""; export const DB_USERNAME = process.env.DB_USERNAME ?? ""; export const DB_PASSWORD = process.env.DB_PASSWORD ?? "";