| 17 | } |
| 18 | |
| 19 | function getCredentials(): Credentials { |
| 20 | if (DB_CONFIG.username) { |
| 21 | return { |
| 22 | username: DB_CONFIG.username, |
| 23 | password: DB_CONFIG.password, |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | switch (SERVICE) { |
| 28 | case configTypes.ServiceType.API: |
| 29 | return { |
| 30 | username: DB_CONFIG.apiUsername, |
| 31 | password: DB_CONFIG.apiPassword, |
| 32 | } |
| 33 | case configTypes.ServiceType.JOB_GENERATOR: |
| 34 | return { |
| 35 | username: DB_CONFIG.jobGeneratorUsername, |
| 36 | password: DB_CONFIG.jobGeneratorPassword, |
| 37 | } |
| 38 | case configTypes.ServiceType.NODEJS_WORKER: |
| 39 | return { |
| 40 | username: DB_CONFIG.nodejsWorkerUsername, |
| 41 | password: DB_CONFIG.nodejsWorkerPassword, |
| 42 | } |
| 43 | default: |
| 44 | throw new Error('Incorrectly configured database connection settings!') |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | function models(queryTimeoutMilliseconds: number) { |
| 49 | const database = {} as any |