Skip to content

Commit

Permalink
Merge branch 'main' into BC-5119-Prevent-creating-new-neXboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaellinaresxk authored Nov 14, 2023
2 parents 1f89c57 + e806f1c commit 0049531
Show file tree
Hide file tree
Showing 135 changed files with 2,562 additions and 5,689 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ data:
}'

# Add Bettermarks' tools configuration as an external tool
# (stored in the 'external_tools' collection) that uses OAuth.
mongosh $DATABASE__URL --eval 'db.external_tools.replaceOne(
# (stored in the 'external-tools' collection) that uses OAuth.
mongosh $DATABASE__URL --eval 'db.external-tools.replaceOne(
{
"name": "bettermarks",
"config_type": "oauth2"
Expand Down Expand Up @@ -486,9 +486,9 @@ data:
echo "POSTed nextcloud to hydra."

# Add Nextcloud' tools configuration as an external tool
# (stored in the 'external_tools' collection) that uses OAuth.
echo "Inserting nextcloud to external_tools..."
mongosh $DATABASE__URL --eval 'db.external_tools.update(
# (stored in the 'external-tools' collection) that uses OAuth.
echo "Inserting nextcloud to external-tools..."
mongosh $DATABASE__URL --eval 'db.external-tools.update(
{
"name": "nextcloud",
"config_type": "oauth2"
Expand All @@ -512,7 +512,7 @@ data:
"upsert": true
}
);'
echo "Inserted nextcloud to external_tools."
echo "Inserted nextcloud to external-tools."

echo "Nextcloud config data init performed successfully."
fi
Expand Down
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 0049531

Please sign in to comment.