From 13578d8c9b2e90a9621c068be1a124cb1bc646a3 Mon Sep 17 00:00:00 2001 From: trivernis Date: Mon, 14 Sep 2020 15:09:43 +0200 Subject: [PATCH 1/3] Switch to environment variables for database url Signed-off-by: trivernis --- ormconfig.json | 12 ------------ src/index.ts | 5 ++++- 2 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 ormconfig.json diff --git a/ormconfig.json b/ormconfig.json deleted file mode 100644 index 250b347..0000000 --- a/ormconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "postgres", - "host": "127.17.42.1", - "port": 5432, - "username": "apollo", - "database": "apollo_test", - "synchronize": true, - "logging": false, - "entities": [ - "dist/model/**/*.js" - ] - } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1d0e8fb..cf9bdff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,10 @@ async function authenticate (req: any, res: any, next: any) { } } -createConnection().then(async () => { +createConnection({ + type: 'postgres', + url: process.env.POSTGRES_CONNECTION_URL +}).then(async () => { console.log('connected to db'); }).catch(error => console.log(error)); From e1312d93bcfc03be2834b7b2e967c6d53441737a Mon Sep 17 00:00:00 2001 From: trivernis Date: Mon, 14 Sep 2020 15:17:36 +0200 Subject: [PATCH 2/3] Fix docker build Signed-off-by: trivernis --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b03e8e..e13b7b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,6 @@ WORKDIR / COPY ./src /src COPY ./package*.json ./ COPY ./gulpfile.js ./tsconfig.json ./ -COPY ./ormconfig.json ./ RUN npm install RUN npm install -g gulp RUN npm install gulp @@ -12,4 +11,4 @@ RUN gulp EXPOSE 4000 EXPOSE 5432 -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "start"] From 449b6bd9ac6d8f56bc53c9821008229d014074bc Mon Sep 17 00:00:00 2001 From: trivernis Date: Mon, 14 Sep 2020 15:45:28 +0200 Subject: [PATCH 3/3] Fix database entity settings Signed-off-by: trivernis --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index cf9bdff..01c7797 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import { createConnection } from 'typeorm'; import { UserServerAPI } from './datasources/userserver/userserviceAPI'; import express from 'express'; import { requiredPermissions } from './datasources/userserver/permission'; +import { CargoBike } from './model/CargoBike'; require('dotenv').config(); @@ -39,7 +40,12 @@ async function authenticate (req: any, res: any, next: any) { createConnection({ type: 'postgres', - url: process.env.POSTGRES_CONNECTION_URL + url: process.env.POSTGRES_CONNECTION_URL, + entities: [ + CargoBike + ], + synchronize: true, + logging: false }).then(async () => { console.log('connected to db'); }).catch(error => console.log(error));