refactor: refactor-to-boilerplate#52
Conversation
There was a problem hiding this comment.
why didn't you create a schema? we don't like custom env variables json
| "database": "postgres", | ||
| "schema": "public" |
There was a problem hiding this comment.
why? If that's how your local db is configured, change it in local.json
| import type { FindOperator } from 'typeorm'; | ||
| import { Between, LessThanOrEqual, MoreThanOrEqual } from 'typeorm'; |
There was a problem hiding this comment.
I know you auto fixed it with vs code. But when you import just one type you can just import it in one line with type before the import
| protocol: string; | ||
| host: string; | ||
| projectId?: string; | ||
| port: string; | ||
| projectId?: string; |
There was a problem hiding this comment.
take this from the configtype - would be much easier with a schema
| { | ||
| token: Connection, | ||
| provider: { useFactory: instancePerContainerCachingFactory(connectionFactory) }, | ||
| postInjectionHook: async (container: DependencyContainer): Promise<void> => { | ||
| const connection = container.resolve<Connection>(Connection); | ||
| await connection.connect(); | ||
| }, | ||
| { | ||
| token: DUMP_METADATA_REPOSITORY_SYMBOL, | ||
| provider: { | ||
| useFactory: (container): Repository<DumpMetadata> => { | ||
| const connection = container.resolve<Connection>(Connection); | ||
| const repository = connection.getRepository(DumpMetadata); | ||
| return repository; | ||
| }, | ||
| }, | ||
| { | ||
| token: DUMP_METADATA_REPOSITORY_SYMBOL, | ||
| provider: { | ||
| useFactory: (container): Repository<DumpMetadata> => { | ||
| const connection = container.resolve<Connection>(Connection); | ||
| return connection.getRepository(DumpMetadata); | ||
| }, | ||
| }, | ||
| { token: DUMP_METADATA_ROUTER_SYMBOL, provider: { useFactory: dumpMetadataRouterFactory } }, | ||
| { | ||
| token: 'healthcheck', | ||
| provider: { useFactory: (container): unknown => getDbHealthCheckFunction(container.resolve<Connection>(Connection)) }, | ||
| }, | ||
| { | ||
| token: 'onSignal', | ||
| provider: { | ||
| useValue: { | ||
| useValue: async (): Promise<void> => { | ||
| await Promise.all([tracing.stop(), otelMetrics.stop(), shutdownHandler.onShutdown()]); | ||
| }, | ||
| }, | ||
| }, | ||
| { token: DUMP_METADATA_ROUTER_SYMBOL, provider: { useFactory: dumpMetadataRouterFactory } }, | ||
| { | ||
| token: SERVICES.HEALTHCHECK, | ||
| provider: { useFactory: (container): HealthCheck => getDbHealthCheckFunction(container.resolve<Connection>(Connection)) }, | ||
| }, | ||
| { | ||
| token: 'onSignal', | ||
| provider: { | ||
| useValue: async (): Promise<void> => { | ||
| await Promise.all([getTracing().stop()]); |
There was a problem hiding this comment.
Why don't you use cleanup registry? Do you want to destroy our project?
| import type { DumpMetadata } from '@src/dumpMetadata/DAL/typeorm/dumpMetadata'; | ||
| import type { RegisterOptions } from '@src/containerConfig'; | ||
| import { SERVICES } from '@common/constants'; | ||
| import { createMultipleFakeDumpsMetadata } from '../../../helpers'; |
There was a problem hiding this comment.
If you removed all the ../../.. for src, why not add a @tests alias?
| const HAPPY_PATH = 'Happy Path 🙂'; | ||
| const SAD_PATH = 'Sad Path 😥'; | ||
| const BAD_PATH = 'Bad Path 😡'; | ||
|
|
||
| export const BEFORE_ALL_TIMEOUT = 20000; | ||
| const BEFORE_ALL_TIMEOUT = 20000; | ||
|
|
||
| export const generateDumpsMetadataOnDb = async (repository: Repository<DumpMetadata>, amount: number): Promise<DumpMetadata[]> => { | ||
| const generateDumpsMetadataOnDb = async (repository: Repository<DumpMetadata>, amount: number): Promise<DumpMetadata[]> => { | ||
| const createdDumpsMetadata = repository.create(createMultipleFakeDumpsMetadata(amount)); | ||
| return repository.save(createdDumpsMetadata); | ||
| }; | ||
|
|
||
| export const getBaseRegisterOptions = (): Required<RegisterOptions> => { | ||
| const getBaseRegisterOptions = async (): Promise<Required<RegisterOptions>> => { | ||
| return { | ||
| override: [ | ||
| { token: Services.LOGGER, provider: { useValue: jsLogger({ enabled: false }) } }, | ||
| { token: Services.TRACER, provider: { useValue: trace.getTracer('testTracer') } }, | ||
| { token: SERVICES.LOGGER, provider: { useValue: await jsLogger({ enabled: false }) } }, | ||
| { token: SERVICES.TRACER, provider: { useValue: trace.getTracer('testTracer') } }, | ||
| ], | ||
| useChild: true, | ||
| }; | ||
| }; | ||
|
|
||
| export { HAPPY_PATH, SAD_PATH, BAD_PATH, BEFORE_ALL_TIMEOUT, generateDumpsMetadataOnDb, getBaseRegisterOptions }; |
| const noopLogger = { | ||
| info: (): void => undefined, | ||
| error: (): void => undefined, | ||
| debug: (): void => undefined, | ||
| warn: (): void => undefined, | ||
| trace: (): void => undefined, | ||
| fatal: (): void => undefined, | ||
| child: (): Logger => noopLogger, | ||
| } as unknown as Logger; |
There was a problem hiding this comment.
Our team manager will kill you for using as unknown as
| import { getDefaultFilter } from '../../helpers'; | ||
| import { DumpNameAlreadyExistsError } from '../../../../src/common/errors'; | ||
|
|
||
| const noopLogger = { |
There was a problem hiding this comment.
I also don't get the sentiment of using a mocked logger instead of logger enabled false like it was before
Related issues: (MAPCO-6292)
Closes (MAPCO-6292)
Further information: