-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(configuration): DRY, pushed database configuration code into a si…
…ngle configurationManager script (#74)
- Loading branch information
1 parent
52bd5c4
commit 6086fe5
Showing
3 changed files
with
101 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export function getDatabaseName(): string { | ||
return process.env.TYPEORM_DATABASE ? process.env.TYPEORM_DATABASE : ''; | ||
} | ||
|
||
export function getDatabaseType(): string { | ||
return process.env.TYPEORM_DATABASE_TYPE ? process.env.TYPEORM_DATABASE_TYPE : 'postgres'; | ||
} | ||
|
||
export function getDatabaseHost(): string { | ||
return process.env.TYPEORM_HOST || 'localhost'; | ||
} | ||
|
||
export function shouldSchronizeDatabaseSchema(): boolean { | ||
return process.env.TYPEORM_SYNCHRONIZE === 'true'; | ||
} | ||
|
||
export function getDatabaseLoggingLevel() { | ||
return process.env.TYPEORM_LOGGING || 'all'; | ||
} | ||
|
||
export function getDatabaseEntityPaths(): string[] { | ||
return process.env.TYPEORM_ENTITIES | ||
? process.env.TYPEORM_ENTITIES.split(',') | ||
: ['src/**/*.model.ts']; | ||
} | ||
|
||
export function getDatabaseMigrationPaths(): string[] { | ||
return process.env.TYPEORM_MIGRATIONS | ||
? process.env.TYPEORM_MIGRATIONS.split(',') | ||
: ['src/migration/**/*.ts']; | ||
} | ||
|
||
export function getDatabaseSubscriberPaths(): string[] { | ||
return process.env.TYPEORM_SUBSCRIBERS | ||
? process.env.TYPEORM_SUBSCRIBERS.split(',') | ||
: ['src/**/*.model.ts']; | ||
} | ||
|
||
export function getDatabaseUsername(): string | undefined { | ||
return process.env.TYPEORM_USERNAME; | ||
} | ||
|
||
export function getDatabasePassword(): string | undefined { | ||
return process.env.TYPEORM_PASSWORD; | ||
} | ||
|
||
export function getDatabasePort(): number { | ||
return parseInt(process.env.TYPEORM_PORT || '', 10) || 5432; | ||
} |