-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(deps): bump jest from ^27.1.1 to ^29.7.0 * fix: updated gitignore file * fix: typeorm nested relations query syntax * chore(deps): bump prettier from ^2.4.0 to ^3.2.5 * fix: run prettier for formatting * fix: run prettier for formatting * fix: typeorm nested relations query syntax * fix: get data source connection for e2e testing * fix: run prettier for formatting * fix: run prettier for formatting * fix: increased jest testTimeout * fix: removed maxWorker for jest * update yarn.lock * chore: update yarn.lock * fix: coderabbitai suggestion * fix: coderabbitai suggestion * chore: update yarn.lock * fix: removed console * style: fix code style issues using Prettier * fix: updated connection datasource
- Loading branch information
1 parent
22a2254
commit 96a2ec4
Showing
49 changed files
with
574 additions
and
200 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { DataSource, DataSourceOptions, DefaultNamingStrategy } from 'typeorm'; | ||
import * as process from 'process'; | ||
import { SnakeNamingStrategy } from '../utils/snake-naming-strategy'; | ||
|
||
const env = process.env; | ||
|
||
/** | ||
* Retrieves the connection options for TypeORM DataSource or TypeORMModule. | ||
* | ||
* @returns The connection options for TypeORM DataSource or TypeORMModule. | ||
*/ | ||
export const dataSourceOptions = (): DataSourceOptions => { | ||
// Safely cast the database type or default to 'mysql' | ||
const dbType = (env.TR_DB_TYPE as any) || 'mysql'; | ||
|
||
// Parse the port safely with fallback to 3306 if parsing fails | ||
const parsedPort = parseInt(env.TR_DB_PORT, 10); | ||
const port = Number.isNaN(parsedPort) ? 3306 : parsedPort; | ||
|
||
// Base options object using the more generic DataSourceOptions | ||
const options: DataSourceOptions = { | ||
type: dbType, | ||
host: env.TR_DB_HOST || '127.0.0.1', | ||
port, | ||
username: env.TR_DB_USER || 'root', | ||
password: env.TR_DB_PASSWORD || '', | ||
database: env.TR_DB_DATABASE || 'tr_dev', | ||
charset: 'utf8mb4', | ||
synchronize: false, | ||
logging: false, | ||
entities: [__dirname + '/../entity/*.entity.{js,ts}'], | ||
migrations: [__dirname + '/../migrations/*.{js,ts}'], | ||
namingStrategy: dbType === 'postgres' ? new SnakeNamingStrategy() : new DefaultNamingStrategy(), | ||
}; | ||
|
||
return options; | ||
}; | ||
|
||
/** | ||
* Creates and initializes a TypeORM DataSource instance with the provided configuration options. | ||
* | ||
* @returns Initialized TypeORM DataSource instance. | ||
*/ | ||
let dataSource: DataSource; | ||
export const getDataSourceConnection = async (): Promise<DataSource> => { | ||
if (!dataSource) { | ||
dataSource = new DataSource(dataSourceOptions()); | ||
} | ||
|
||
try { | ||
if (!dataSource.isInitialized) { | ||
await dataSource.initialize(); | ||
} | ||
} catch (error) { | ||
console.error(`Error initializing database connection: ${error?.message}`); | ||
} | ||
|
||
return dataSource; | ||
}; |
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
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
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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
{ | ||
"term": { | ||
"one": "data.VWAnalyticssaleorder.docdate.day", | ||
"two": { | ||
"hour": "data.VWAnalyticssaleorder.docdate" | ||
}, | ||
"three": "UPDATE_SCHEDULER_SCREEN.EDIT_EVENT.HOURS" | ||
"term": { | ||
"one": "data.VWAnalyticssaleorder.docdate.day", | ||
"two": { | ||
"hour": "data.VWAnalyticssaleorder.docdate" | ||
}, | ||
"data": { | ||
"VWAnalyticssaleorder": { | ||
"docdate": { | ||
"day": "foo" | ||
} | ||
} | ||
}, | ||
"UPDATE_SCHEDULER_SCREEN": { | ||
"EDIT_EVENT": { | ||
"HOURS": "bar" | ||
} | ||
"three": "UPDATE_SCHEDULER_SCREEN.EDIT_EVENT.HOURS" | ||
}, | ||
"data": { | ||
"VWAnalyticssaleorder": { | ||
"docdate": { | ||
"day": "foo" | ||
} | ||
} | ||
}, | ||
"UPDATE_SCHEDULER_SCREEN": { | ||
"EDIT_EVENT": { | ||
"HOURS": "bar" | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"term.one": "Current Plan: {{ project.plan.name }}", | ||
"term two": "{VAR_PLURAL, plural, =0 {locales} =1 {locale} other {locales} }", | ||
"TERM_THREE": "Export format...", | ||
"term:four": "hello there you\\nthis should be in a newline" | ||
} | ||
"term.one": "Current Plan: {{ project.plan.name }}", | ||
"term two": "{VAR_PLURAL, plural, =0 {locales} =1 {locale} other {locales} }", | ||
"TERM_THREE": "Export format...", | ||
"term:four": "hello there you\\nthis should be in a newline" | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"term": { | ||
"one": "Current Plan: {{ project.plan.name }}" | ||
}, | ||
"term two": "{VAR_PLURAL, plural, =0 {locales} =1 {locale} other {locales} }", | ||
"TERM_THREE": "Export format...", | ||
"term:four": "hello there you\\nthis should be in a newline" | ||
} | ||
"term": { | ||
"one": "Current Plan: {{ project.plan.name }}" | ||
}, | ||
"term two": "{VAR_PLURAL, plural, =0 {locales} =1 {locale} other {locales} }", | ||
"TERM_THREE": "Export format...", | ||
"term:four": "hello there you\\nthis should be in a newline" | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": ".", | ||
"testEnvironment": "node", | ||
"testTimeout": 60000, | ||
"testRegex": ".e2e-spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
} | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": ".", | ||
"testEnvironment": "node", | ||
"testTimeout": 120000, | ||
"testRegex": ".e2e-spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
} | ||
} |
Oops, something went wrong.