diff --git a/README.md b/README.md index 682dd5f..cd25810 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,6 @@ POSTGRES_CONNECTION_URL=postgres://username:password@host:port/database_name ``` - __RPC_HOST__ is used for the connection with the [flotte-user-management server](https://github.com/fLotte-meets-HWR-DB/flotte-user-management). - __NODE_ENV__ will not check authentication if set to development -- __POSTGRES_CONNECTION_URL__ for connection with the postgres database +- __DATABASE_URL__ for connection with the postgres database If the API server cannot connect to the [flotte-user-management server](https://github.com/fLotte-meets-HWR-DB/flotte-user-management) or the postgres data base. It will try to reconnect in an endless loop. diff --git a/src/app.ts b/src/app.ts index 4eaceb4..9e5d13f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -62,9 +62,8 @@ require('dotenv').config(); export const userAPI = new UserServerAPI(process.env.RPC_HOST); export function getConnectionOptions (): ConnectionOptions { - return { - // @ts-ignore - type: process.env.DATABASE_TYPE, + const ret = { + type: (!process.env.DATABASE_TYPE) ? 'postgres' : process.env.DATABASE_TYPE, url: process.env.DATABASE_URL, database: process.env.DATABASE_NAME, entities: [ @@ -89,6 +88,11 @@ export function getConnectionOptions (): ConnectionOptions { synchronize: true, logging: false }; + if (ret.database === undefined) { + delete ret.database; + } + // @ts-ignore + return ret; } export async function getApp (connOptions: ConnectionOptions) {