README + src/app.ts: change env vars

also set default parameters for databese and driver
pull/31/head
leonnicolas 4 years ago
parent 0268a4cc86
commit 8121599fcd
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -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.

@ -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) {

Loading…
Cancel
Save