Skip to content

Commit

Permalink
Merge branch 'main' into BC-5583-display-pdf-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax authored Nov 13, 2023
2 parents 19f4eda + 034cab8 commit 8925810
Show file tree
Hide file tree
Showing 36 changed files with 1,494 additions and 538 deletions.
29 changes: 21 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,24 @@ module.exports = {
overrides: [
{
files: ['apps/**/*.ts'],
env: {
node: true,
es6: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint/eslint-plugin'],
parserOptions: {
project: 'apps/server/tsconfig.lint.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'import'],
extends: [
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:promise/recommended',
'plugin:import/typescript',
],
parserOptions: {
project: 'apps/server/tsconfig.lint.json',
},
env: {
node: true,
es6: true,
},
rules: {
'import/no-unresolved': 'off', // better handled by ts resolver
'import/no-extraneous-dependencies': 'off', // better handles by ts resolver
Expand All @@ -98,6 +100,17 @@ module.exports = {
allowSingleExtends: true,
},
],
'@typescript-eslint/no-restricted-imports': [
'warn',
{
patterns: [
{
group: ['@infra/*/*', '@modules/*/*', '!*.module'],
message: 'Do not deep import from a module',
},
],
},
],
},
overrides: [
{
Expand Down
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
2 changes: 1 addition & 1 deletion apps/server/src/apps/server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ExpressAdapter } from '@nestjs/platform-express';
import { enableOpenApiDocs } from '@shared/controller/swagger';
import { Mail, MailService } from '@infra/mail';
import { LegacyLogger, Logger } from '@src/core/logger';
import { AccountService } from '@modules/account/services/account.service';
import { AccountService } from '@modules/account';
import { TeamService } from '@modules/teams/service/team.service';

Check warning on line 11 in apps/server/src/apps/server.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'@modules/teams/service/team.service' import is restricted from being used by a pattern. Do not deep import from a module
import { AccountValidationService } from '@modules/account/services/account.validation.service';

Check warning on line 12 in apps/server/src/apps/server.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'@modules/account/services/account.validation.service' import is restricted from being used by a pattern. Do not deep import from a module
import { AccountUc } from '@modules/account/uc/account.uc';

Check warning on line 13 in apps/server/src/apps/server.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'@modules/account/uc/account.uc' import is restricted from being used by a pattern. Do not deep import from a module
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';
Loading

0 comments on commit 8925810

Please sign in to comment.