Skip to content

Commit

Permalink
Merge branch 'main' into BC-4710-new-tldraw-manage
Browse files Browse the repository at this point in the history
# Conflicts:
#	config/default.schema.json
  • Loading branch information
blazejpass committed Nov 16, 2023
2 parents 12a5dd9 + 88e6c5f commit 83525cf
Show file tree
Hide file tree
Showing 221 changed files with 4,900 additions and 6,121 deletions.
31 changes: 31 additions & 0 deletions apps/server/src/apps/deletion-console.app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* istanbul ignore file */
import { BootstrapConsole } from 'nestjs-console';
import { DeletionConsoleModule } from '@modules/deletion';

async function run() {
const bootstrap = new BootstrapConsole({
module: DeletionConsoleModule,
useDecorators: true,
});

const app = await bootstrap.init();

try {
await app.init();

// Execute console application with provided arguments.
await bootstrap.boot();
} catch (err) {
// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-call
console.error(err);

// Set the exit code to 1 to indicate a console app failure.
process.exitCode = 1;
}

// Always close the app, even if some exception
// has been thrown from the console app.
await app.close();
}

void run();
32 changes: 32 additions & 0 deletions apps/server/src/core/error/loggable/axios-error.loggable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { axiosErrorFactory } from '@shared/testing/factory';
import { AxiosError } from 'axios';
import { AxiosErrorLoggable } from './axios-error.loggable';

describe(AxiosErrorLoggable.name, () => {
describe('getLogMessage', () => {
const setup = () => {
const error = {
error: 'invalid_request',
};
const type = 'mockType';
const axiosError: AxiosError = axiosErrorFactory.withError(error).build();

const axiosErrorLoggable = new AxiosErrorLoggable(axiosError, type);

return { axiosErrorLoggable, error, axiosError };
};

it('should return error log message', () => {
const { axiosErrorLoggable, error, axiosError } = setup();

const result = axiosErrorLoggable.getLogMessage();

expect(result).toEqual({
type: 'mockType',
message: axiosError.message,
data: JSON.stringify(error),
stack: 'mockStack',
});
});
});
});
20 changes: 20 additions & 0 deletions apps/server/src/core/error/loggable/axios-error.loggable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { HttpException, HttpStatus } from '@nestjs/common';
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger';
import { AxiosError } from 'axios';

export class AxiosErrorLoggable extends HttpException implements Loggable {
constructor(private readonly axiosError: AxiosError, protected readonly type: string) {
super(JSON.stringify(axiosError.response?.data), axiosError.status ?? HttpStatus.INTERNAL_SERVER_ERROR, {
cause: axiosError.cause,
});
}

getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage {
return {
message: this.axiosError.message,
type: this.type,
data: JSON.stringify(this.axiosError.response?.data),
stack: this.axiosError.stack,
};
}
}
2 changes: 2 additions & 0 deletions apps/server/src/core/error/loggable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './error.loggable';
export * from './axios-error.loggable';
2 changes: 1 addition & 1 deletion apps/server/src/core/logger/types/logging.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type ErrorLogMessage = {
error?: Error;
type: string; // TODO: use enum
stack?: string;
data?: { [key: string]: string | number | undefined };
data?: { [key: string]: string | number | boolean | undefined };
};

export type ValidationErrorLogMessage = {
Expand Down
Loading

0 comments on commit 83525cf

Please sign in to comment.