Skip to content

Commit

Permalink
style: fix code style issues using Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket committed Oct 18, 2024
1 parent 9d03935 commit 8eb3d11
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 105 deletions.
74 changes: 37 additions & 37 deletions api/src/connection/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ const env = process.env;
* @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 || 'localhost',
port,
username: env.TR_DB_USER || 'root',
password: env.TR_DB_PASSWORD || 'root',
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;
// 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 || 'localhost',
port,
username: env.TR_DB_USER || 'root',
password: env.TR_DB_PASSWORD || 'root',
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;
};

/**
Expand All @@ -43,17 +43,17 @@ export const dataSourceOptions = (): DataSourceOptions => {
*/
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;
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;
};
36 changes: 18 additions & 18 deletions api/src/formatters/fixtures/function-name-nested.json
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"
}
}
}
}
10 changes: 5 additions & 5 deletions api/src/formatters/fixtures/simple-flat.json
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"
}
14 changes: 7 additions & 7 deletions api/src/formatters/fixtures/simple-nested.json
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"
}
22 changes: 9 additions & 13 deletions api/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testEnvironment": "node",
"testTimeout": 120000,
"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"
}
}
6 changes: 1 addition & 5 deletions api/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
},
"rulesDirectory": [],
"linterOptions": {
"exclude": [
"bin",
"src/migrations/*",
"**/*.json"
]
"exclude": ["bin", "src/migrations/*", "**/*.json"]
}
}
8 changes: 2 additions & 6 deletions webapp/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles.scss"
],
"styles": ["src/styles.scss"],
"scripts": [],
"allowedCommonJsDependencies": [
"lodash"
]
"allowedCommonJsDependencies": ["lodash"]
},
"configurations": {
"production": {
Expand Down
14 changes: 6 additions & 8 deletions webapp/e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
specs: ['./src/**/*.e2e-spec.ts'],
capabilities: {
'browserName': 'chrome'
browserName: 'chrome',
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
print: function () {},
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
project: require('path').join(__dirname, './tsconfig.e2e.json'),
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
},
};
8 changes: 2 additions & 6 deletions webapp/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
"types": ["jasmine", "jasminewd2", "node"]
}
}
}

0 comments on commit 8eb3d11

Please sign in to comment.