Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/backend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
},
rules: {
'no-console': 'off',
'@typescript-eslint/comma-dangle': ['error', 'only-multiline'],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down Expand Up @@ -60,6 +61,7 @@ module.exports = {
}
}
],
'comma-dangle': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"trailingComma": "es5",
"arrowParens": "always",
"tabWidth": 2,
"useTabs": false,
Expand Down
14 changes: 7 additions & 7 deletions apps/backend/src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
BadRequestException,
ValidationError,
ValidationPipe,
ValidationPipeOptions
ValidationPipeOptions,
} from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import {
ExpressAdapter,
NestExpressApplication
NestExpressApplication,
} from '@nestjs/platform-express';
import express from 'express';

Expand Down Expand Up @@ -38,7 +38,7 @@ export const validationPipeConfig: ValidationPipeOptions = {
if (error.constraints) {
messages.push({
property: error.property,
errors: Object.values(error.constraints)
errors: Object.values(error.constraints),
});
}
if (error.children && error.children?.length > 0) {
Expand All @@ -52,7 +52,7 @@ export const validationPipeConfig: ValidationPipeOptions = {
};
const errorMessages = errors.map((error) => getErrorMessages(error));
throw new BadRequestException(errorMessages);
}
},
};

export async function createNestApp(): Promise<{
Expand All @@ -70,7 +70,7 @@ export async function createNestApp(): Promise<{
process.env.RUNTIME_ENV === 'test'
) {
app = await NestFactory.create(AppModule, {
bufferLogs: true
bufferLogs: true,
});
app.useLogger(app.get(AppLogger));
} else {
Expand Down Expand Up @@ -105,11 +105,11 @@ export async function createNestApp(): Promise<{
envName: process.env.ENV_NAME,
nodeEnv: process.env.NODE_ENV,
runtimeEnv: process.env.RUNTIME_ENV,
alertsEnabled: Boolean(false)
alertsEnabled: Boolean(false),
});

return {
app,
expressApp
expressApp,
};
}
2 changes: 1 addition & 1 deletion apps/backend/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AppController {
@ApiOperation({})
getHealth(): object {
return {
status: 'ok'
status: 'ok',
};
}
}
12 changes: 6 additions & 6 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { TransactionModule } from './transaction/transaction.module';
ignoreEnvFile:
process.env.RUNTIME_ENV === 'local' || process.env.RUNTIME_ENV === 'ci'
? false
: true
: true,
}),
AwsSdkModule.forRoot({
defaultServiceOptions: {
Expand All @@ -42,14 +42,14 @@ import { TransactionModule } from './transaction/transaction.module';
? {
endpoint: process.env.AWS_ENDPOINT || 'http://localhost:9000',
region: 'ca-central-1',
s3ForcePathStyle: true
s3ForcePathStyle: true,
}
: {})
: {}),
},
services: [S3]
})
services: [S3],
}),
],
controllers: [AppController],
providers: [AppService]
providers: [AppService],
})
export class AppModule {}
2 changes: 1 addition & 1 deletion apps/backend/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class AppService {
return {
buildId: process.env.BUILD_ID ?? 'NA',
info: process.env.BUILD_INFO ?? 'NA',
env: process.env.ENV_NAME ?? 'NA'
env: process.env.ENV_NAME ?? 'NA',
};
}
}
8 changes: 4 additions & 4 deletions apps/backend/src/common/common.errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ export const CommonError = {
INTERNAL_ERROR: {
errorType: 'INTERNAL_ERROR',
errorMessage: 'Internal Server Error',
httpStatus: HttpStatus.INTERNAL_SERVER_ERROR
httpStatus: HttpStatus.INTERNAL_SERVER_ERROR,
} as GenericError,

FAILED_FIELD_VALIDATION: {
errorType: 'FAILED_FIELD_VALIDATION',
errorMessage:
'Some fields were rejected. Please, check your information and try again.',
httpStatus: HttpStatus.PRECONDITION_FAILED
httpStatus: HttpStatus.PRECONDITION_FAILED,
} as GenericError,

GATEWAY_TIMEOUT: {
errorType: 'GATEWAY_TIMEOUT',
errorMessage: 'Gateway Timeout',
httpStatus: HttpStatus.GATEWAY_TIMEOUT
} as GenericError
httpStatus: HttpStatus.GATEWAY_TIMEOUT,
} as GenericError,
};
8 changes: 4 additions & 4 deletions apps/backend/src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ export enum MatchStatus {
PENDING = 'PENDING',
IN_PROGRESS = 'IN_PROGRESS',
MATCH = 'MATCH',
EXCEPTION = 'EXCEPTION'
EXCEPTION = 'EXCEPTION',
}

export const MatchStatusAll = [
MatchStatus.EXCEPTION,
MatchStatus.MATCH,
MatchStatus.PENDING,
MatchStatus.IN_PROGRESS
MatchStatus.IN_PROGRESS,
];

export enum TransactionCode {
Expand All @@ -18,9 +18,9 @@ export enum TransactionCode {
PREAUTH_PURCHASE_COMPLETE = 12,
MERCH_RETURN = 14,
PURCHASE_ADJUSTMENT = 21,
MERCH_RETURN_ADJUSTMENT = 22
MERCH_RETURN_ADJUSTMENT = 22,
}

export enum Dates {
FISCAL_YEAR_START_DATE = '2023-01-01'
FISCAL_YEAR_START_DATE = '2023-01-01',
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export enum DataType {
Card = 'Card',
TransactionCode = 'TransactionCode',
TransactionType = 'TransactionType',
MerchantLocation = 'MerchantLocation'
MerchantLocation = 'MerchantLocation',
}

export const ColumnMetadataKey = Symbol('Column:metadata');
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/common/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Documentation = (app: INestApplication) => {
.build();

const baseDocument = SwaggerModule.createDocument(app, options, {
include: [TransactionModule, ParseModule, ReconciliationModule, AppModule]
include: [TransactionModule, ParseModule, ReconciliationModule, AppModule],
});

SwaggerModule.setup('api', app, baseDocument, {
Expand All @@ -24,7 +24,7 @@ export const Documentation = (app: INestApplication) => {
operationsSorter: 'alpha',
tagsSorter: 'alpha',
defaultModelsExpandDepth: 2,
defaultModelExpandDepth: 2
}
defaultModelExpandDepth: 2,
},
});
};
10 changes: 5 additions & 5 deletions apps/backend/src/common/entities/FixedWidthRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
ColumnMetadataKey,
ColumnOptions,
ColumnVariableKey,
DataType
DataType,
} from '../decorators/fixedWidthRecord.decorator';
import {
decimalFormat,
timeFormat,
parseFlatDateString
parseFlatDateString,
} from '../utils/format';

type DelimiterOptions = {
Expand Down Expand Up @@ -96,7 +96,7 @@ export class FixedWidthRecord<T extends IFixedWidthRecord<T>>
// get `__proto__` and (recursively) all parent classes
const rs = new Set([
...(fields || []),
...this.getAllFields(Object.getPrototypeOf(clz))
...this.getAllFields(Object.getPrototypeOf(clz)),
]);
return Array.from(rs);
}
Expand All @@ -111,7 +111,7 @@ export class FixedWidthRecord<T extends IFixedWidthRecord<T>>
);
return {
field,
options
options,
};
});
fieldsWithMeta.sort((a, b) => {
Expand All @@ -133,7 +133,7 @@ export class FixedWidthRecord<T extends IFixedWidthRecord<T>>
result = Buffer.concat([
result.slice(0, pos + 1),
Buffer.from(target.delimiter?.value),
result.slice(pos + 1)
result.slice(pos + 1),
]);
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/common/error-exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
HttpException,
HttpStatus,
Logger,
Inject
Inject,
} from '@nestjs/common';
import { Response } from 'express';
import { CommonError } from './common.errors';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ErrorExceptionFilter implements ExceptionFilter {
(exception as any)?.response?.message ||
CommonError.INTERNAL_ERROR.errorMessage,

errorDetails: {}
errorDetails: {},
};
}

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/common/generic-exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class GenericException extends HttpException {
super(
{
error: error.errorType,
message: error.errorMessage || originalError?.message
message: error.errorMessage || originalError?.message,
},
errorCode
);
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/common/promises.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export async function mapLimit<T, R>(
arr: T[],
fn: (x: T , i: number) => Promise<R>,
fn: (x: T, i: number) => Promise<R>,
limit = 10
): Promise<R[]> {
if (limit < 1) {
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/common/ro/empty-response.ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class EmptyResponse {
`,
example: {},
nullable: false,
required: true
required: true,
})
// eslint-disable-next-line @typescript-eslint/ban-types
data!: {};
Expand Down
15 changes: 7 additions & 8 deletions apps/backend/src/common/transformers/numericColumnTransformer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

export class ColumnNumericTransformer {
to(data: number): number {
return data;
}
from(data: string): number {
return parseFloat(data);
}
}
to(data: number): number {
return data;
}
from(data: string): number {
return parseFloat(data);
}
}
8 changes: 4 additions & 4 deletions apps/backend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ export const ALL = 'all';

export enum Ministries {
SBC = 'SBC',
LABOUR = 'LABOUR'
LABOUR = 'LABOUR',
}

export enum FileTypes {
TDI17 = 'TDI17',
TDI34 = 'TDI34',
DDF = 'DDF',
SBC_SALES = 'SBC_SALES'
SBC_SALES = 'SBC_SALES',
}

export enum FileNames {
TDI17 = 'F08TDI17',
TDI34 = 'F08TDI34',
SBC_SALES = 'SBC_SALES'
SBC_SALES = 'SBC_SALES',
}

export interface ParseArgsTDI {
Expand All @@ -33,5 +33,5 @@ export interface DateRange {
export enum PaymentMethodClassification {
CASH = 'CASH',
POS = 'POS',
IGNORE = 'IGNORE'
IGNORE = 'IGNORE',
}
8 changes: 6 additions & 2 deletions apps/backend/src/database/database-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ export class DatabaseLogger implements TypeOrmLogger {

logQueryError(error: string, query: string, parameters?: unknown[]) {
this.logger.error(
`${query} -- Parameters: ${this.stringifyParameters(parameters)} -- ${error}`,
`${query} -- Parameters: ${this.stringifyParameters(
parameters
)} -- ${error}`
);
}

logQuerySlow(time: number, query: string, parameters?: unknown[]) {
this.logger.warn(
`Time: ${time} -- Parameters: ${this.stringifyParameters(parameters)} -- ${query}`,
`Time: ${time} -- Parameters: ${this.stringifyParameters(
parameters
)} -- ${query}`
);
}

Expand Down
Loading