@novo-learning/service-lib 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/clients/auth-api/auth.service.js +1 -1
- package/dist/modules/clients/auth-api/auth.service.js.map +1 -1
- package/dist/modules/clients/publisher-api/publisher.service.js +3 -3
- package/dist/modules/clients/publisher-api/publisher.service.js.map +1 -1
- package/dist/modules/db-migration/schema/db-migration.schema.d.ts +2 -2
- package/dist/modules/nest/http/http.service.d.ts +3 -1
- package/dist/modules/nest/http/http.service.js +50 -18
- package/dist/modules/nest/http/http.service.js.map +1 -1
- package/dist/modules/nest/http/http.service.spec.js +61 -45
- package/dist/modules/nest/http/http.service.spec.js.map +1 -1
- package/dist/modules/nest/jwt/strategies/jwt.strategy.d.ts +1 -3
- package/dist/modules/nest/logger/iso-logger.spec.js.map +1 -1
- package/package.json +20 -21
- package/dist/modules/clients/exercise-api/exercise-api.module.d.ts +0 -4
- package/dist/modules/clients/exercise-api/exercise-api.module.js +0 -30
- package/dist/modules/clients/exercise-api/exercise-api.module.js.map +0 -1
- package/dist/modules/clients/exercise-api/exercise.service.d.ts +0 -23
- package/dist/modules/clients/exercise-api/exercise.service.js +0 -83
- package/dist/modules/clients/exercise-api/exercise.service.js.map +0 -1
- package/dist/modules/nest/exceptions/invalid-request.filter.d.ts +0 -4
- package/dist/modules/nest/exceptions/invalid-request.filter.js +0 -33
- package/dist/modules/nest/exceptions/invalid-request.filter.js.map +0 -1
- package/dist/modules/nest/exceptions/invalid-request.filter.spec.d.ts +0 -1
- package/dist/modules/nest/exceptions/invalid-request.filter.spec.js +0 -49
- package/dist/modules/nest/exceptions/invalid-request.filter.spec.js.map +0 -1
- package/dist/modules/nest/exceptions/request-aborted.filter.d.ts +0 -4
- package/dist/modules/nest/exceptions/request-aborted.filter.js +0 -26
- package/dist/modules/nest/exceptions/request-aborted.filter.js.map +0 -1
- package/dist/modules/nest/exceptions/request-aborted.filter.spec.d.ts +0 -1
- package/dist/modules/nest/exceptions/request-aborted.filter.spec.js +0 -26
- package/dist/modules/nest/exceptions/request-aborted.filter.spec.js.map +0 -1
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.d.ts +0 -4
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.js +0 -31
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.js.map +0 -1
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.spec.d.ts +0 -1
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.spec.js +0 -49
- package/dist/modules/nest/exceptions/unsupported-encoding.filter.spec.js.map +0 -1
|
@@ -47,7 +47,7 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
47
47
|
publisherToken: token,
|
|
48
48
|
userData: { userId: userId, permissions: permissions, publisherId: id },
|
|
49
49
|
}, { headers: { Authorization: `Bearer ${auth?.authData?.payload?.token}` } });
|
|
50
|
-
this.cacheManager.set(this.makeKey(id), new auth_1.Auth(sso.data.data), (0.95 * sso.data.data.payload.refresh_token_expires_in) / 1000);
|
|
50
|
+
this.cacheManager.set(this.makeKey(id), new auth_1.Auth(sso.data.data), { ttl: (0.95 * sso.data.data.payload.refresh_token_expires_in) / 1000 });
|
|
51
51
|
return sso.data.data;
|
|
52
52
|
}
|
|
53
53
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../../src/modules/clients/auth-api/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsD;AACtD,2CAA4D;AAC5D,sDAAwG;AAExG,0CAAkD;AAClD,iCAA8B;AAIvB,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAMtB,YACmB,WAA4B,EAC3B,MAA+B,EAC1B,YAAoC;QAF1C,gBAAW,GAAX,WAAW,CAAiB;QACV,WAAM,GAAN,MAAM,CAAQ;QACT,iBAAY,GAAZ,YAAY,CAAO;QAR5C,YAAO,GAAG,CAAC,EA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B,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAChB,IAAI,WAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,GAAG,IAAI,EAAE,CACxE,CAAC;YAEF,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,KAAK,GAAG,GAAG,aAAW,CAAC,IAAI,KAAK,IAAA,sBAAW,EAAC,GAAG,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF,CAAA;AA1DY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IASR,WAAA,IAAA,eAAM,EAAC,gBAAQ,CAAC,CAAA;IAChB,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;qCAFQ,sBAAe;GAPpC,WAAW,CA0DvB"}
|
|
@@ -43,7 +43,7 @@ let PublisherService = PublisherService_1 = class PublisherService {
|
|
|
43
43
|
const { data: publisher } = await this.api.getAndValidatePublisher(id, undefined, undefined, {
|
|
44
44
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
45
45
|
});
|
|
46
|
-
await this.cacheManager.set(this.makeKey(id), publisher, this.cacheTtl);
|
|
46
|
+
await this.cacheManager.set(this.makeKey(id), publisher, { ttl: this.cacheTtl });
|
|
47
47
|
return publisher;
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
|
@@ -51,7 +51,7 @@ let PublisherService = PublisherService_1 = class PublisherService {
|
|
|
51
51
|
this.logger.error(error);
|
|
52
52
|
const cachedPublisher = await this.cacheManager.get(this.makeKey(id));
|
|
53
53
|
if (cachedPublisher) {
|
|
54
|
-
await this.cacheManager.set(this.makeKey(id), cachedPublisher, this.cacheTtl);
|
|
54
|
+
await this.cacheManager.set(this.makeKey(id), cachedPublisher, { ttl: this.cacheTtl });
|
|
55
55
|
return cachedPublisher;
|
|
56
56
|
}
|
|
57
57
|
return { id, settings: publisher_settings_default_1.DEFAULT_PUBLISHER_SETTINGS };
|
|
@@ -78,7 +78,7 @@ let PublisherService = PublisherService_1 = class PublisherService {
|
|
|
78
78
|
const { data: configurations } = await this.configApi.getAllConfigurations(language, {
|
|
79
79
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
80
80
|
});
|
|
81
|
-
await this.cacheManager.set('lang_' + language, configurations, this.cacheTtl);
|
|
81
|
+
await this.cacheManager.set('lang_' + language, configurations, { ttl: this.cacheTtl });
|
|
82
82
|
return configurations;
|
|
83
83
|
}
|
|
84
84
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher.service.js","sourceRoot":"","sources":["../../../../src/modules/clients/publisher-api/publisher.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAgD;AAChD,sDAQiC;AACjC,6CAAqC;AAErC,+DAA+D;AAC/D,2DAAuD;AACvD,6EAA0E;AAO1E,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAQ3B,YACmB,WAA4B,EAC5B,WAAwB,EAClB,MAA+B,EACrC,YAAmB,EACP,QAAiC,EACtC,IAA6B,EAC5B,KAA8B;QANtC,gBAAW,GAAX,WAAW,CAAiB;QAC5B,gBAAW,GAAX,WAAW,CAAa;QACD,WAAM,GAAN,MAAM,CAAQ;QACrC,iBAAY,GAAZ,YAAY,CAAO;QACU,aAAQ,GAAR,QAAQ,CAAQ;QACrB,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAQ;QAXxC,WAAM,GAAW,IAAI,eAAM,CAAC,kBAAkB,CAAC,CAAC;QAEhD,YAAO,GAAG,CAAC,EAAU,EAAU,EAAE,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hC,gBAAgB,CAyG5B"}
|
|
@@ -5,11 +5,11 @@ export declare class SchemaDbMigration {
|
|
|
5
5
|
name: string;
|
|
6
6
|
performedAt: Date;
|
|
7
7
|
}
|
|
8
|
-
export declare const DbMigrationSchema: import("mongoose").Schema<SchemaDbMigration, import("mongoose").Model<SchemaDbMigration, any, any, any, Document<unknown, any, SchemaDbMigration> & SchemaDbMigration & {
|
|
8
|
+
export declare const DbMigrationSchema: import("mongoose").Schema<SchemaDbMigration, import("mongoose").Model<SchemaDbMigration, any, any, any, Document<unknown, any, SchemaDbMigration, any, {}> & SchemaDbMigration & {
|
|
9
9
|
_id: import("mongoose").Types.ObjectId;
|
|
10
10
|
} & {
|
|
11
11
|
__v: number;
|
|
12
|
-
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, SchemaDbMigration, Document<unknown, {}, import("mongoose").FlatRecord<SchemaDbMigration
|
|
12
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, SchemaDbMigration, Document<unknown, {}, import("mongoose").FlatRecord<SchemaDbMigration>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<SchemaDbMigration> & {
|
|
13
13
|
_id: import("mongoose").Types.ObjectId;
|
|
14
14
|
} & {
|
|
15
15
|
__v: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpService } from '@nestjs/axios';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
2
3
|
export declare class NovoHttpService extends HttpService {
|
|
3
4
|
private readonly logger;
|
|
4
|
-
constructor(axiosRef?:
|
|
5
|
+
constructor(axiosRef?: AxiosInstance);
|
|
6
|
+
private hasRetryConfig;
|
|
5
7
|
}
|
|
@@ -14,34 +14,66 @@ exports.NovoHttpService = void 0;
|
|
|
14
14
|
const axios_1 = require("@nestjs/axios");
|
|
15
15
|
const common_1 = require("@nestjs/common");
|
|
16
16
|
const axios_2 = require("axios");
|
|
17
|
+
const http = require("http");
|
|
18
|
+
const https = require("https");
|
|
17
19
|
let NovoHttpService = NovoHttpService_1 = class NovoHttpService extends axios_1.HttpService {
|
|
18
|
-
constructor(axiosRef = axios_2.default.create(
|
|
20
|
+
constructor(axiosRef = axios_2.default.create({
|
|
21
|
+
timeout: 3000,
|
|
22
|
+
httpAgent: new http.Agent({ keepAlive: false, maxSockets: 100 }),
|
|
23
|
+
httpsAgent: new https.Agent({ keepAlive: false, maxSockets: 100 }),
|
|
24
|
+
maxRedirects: 0,
|
|
25
|
+
validateStatus: (status) => status < 500,
|
|
26
|
+
})) {
|
|
19
27
|
super(axiosRef);
|
|
20
28
|
this.logger = new common_1.Logger(NovoHttpService_1.name);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
this.axiosRef.interceptors.request.use((config) => {
|
|
30
|
+
config.__retryCount = config.__retryCount ?? 0;
|
|
31
|
+
config.__maxRetries = config.__maxRetries ?? 2;
|
|
32
|
+
config.__retryDelay = config.__retryDelay ?? 200;
|
|
33
|
+
return config;
|
|
34
|
+
});
|
|
35
|
+
this.axiosRef.interceptors.response.use((res) => res, async (error) => {
|
|
36
|
+
if (!error.config) {
|
|
37
|
+
return Promise.reject(error);
|
|
38
|
+
}
|
|
39
|
+
console.log('IN NOVO HTTP SERVICE');
|
|
40
|
+
const config = error.config;
|
|
41
|
+
console.log('IN NOVO HTTP SERVICE');
|
|
42
|
+
const retryable = this.hasRetryConfig(config) &&
|
|
43
|
+
(error.code === 'ECONNABORTED' ||
|
|
44
|
+
error.code === 'ETIMEDOUT' ||
|
|
45
|
+
error.code === 'EPIPE' ||
|
|
46
|
+
error.code === 'ENETUNREACH' ||
|
|
47
|
+
error.code === 'EAI_AGAIN' ||
|
|
48
|
+
error.response?.status === 503 ||
|
|
49
|
+
error.response?.status === 500 ||
|
|
50
|
+
error.response?.status === 502 ||
|
|
51
|
+
error.response?.status === 504);
|
|
52
|
+
console.log('IN NOVO HTTP SERVICE: ' + retryable);
|
|
53
|
+
console.log('IN NOVO HTTP SERVICE: ' + error.code);
|
|
54
|
+
if (!retryable) {
|
|
55
|
+
console.log('NOT RETRYABLE');
|
|
56
|
+
return Promise.reject(error);
|
|
25
57
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
58
|
+
if (config.__retryCount >= config.__maxRetries) {
|
|
59
|
+
console.log('MAX EXCEEDED');
|
|
60
|
+
return Promise.reject(error);
|
|
28
61
|
}
|
|
29
|
-
config.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
await delayRetryRequest;
|
|
37
|
-
return (0, axios_2.default)(config);
|
|
62
|
+
config.__retryCount += 1;
|
|
63
|
+
this.logger.warn(`Retrying request (${config.__retryCount}/${config.__maxRetries}) → ${config.url}`);
|
|
64
|
+
console.log('IN NOVO HTTP SERVIC VOOR E');
|
|
65
|
+
await new Promise((resolve) => setTimeout(resolve, config.__retryDelay));
|
|
66
|
+
console.log('IN NOVO HTTP SERVICE NA');
|
|
67
|
+
return this.axiosRef(config);
|
|
38
68
|
});
|
|
39
|
-
|
|
69
|
+
}
|
|
70
|
+
hasRetryConfig(config) {
|
|
71
|
+
return config.__maxRetries != null && config.__retryCount != null && config.__retryDelay != null;
|
|
40
72
|
}
|
|
41
73
|
};
|
|
42
74
|
exports.NovoHttpService = NovoHttpService;
|
|
43
75
|
exports.NovoHttpService = NovoHttpService = NovoHttpService_1 = __decorate([
|
|
44
76
|
(0, common_1.Injectable)(),
|
|
45
|
-
__metadata("design:paramtypes", [
|
|
77
|
+
__metadata("design:paramtypes", [Function])
|
|
46
78
|
], NovoHttpService);
|
|
47
79
|
//# sourceMappingURL=http.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.service.js","sourceRoot":"","sources":["../../../../src/modules/nest/http/http.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":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M,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YACrG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAE1C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;YAEzE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;YACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,MAA6B;QAClD,OAAO,MAAM,CAAC,YAAY,IAAI,IAAI,IAAI,MAAM,CAAC,YAAY,IAAI,IAAI,IAAI,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;IACnG,CAAC;CACF,CAAA;AAzEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;;GACA,eAAe,CAyE3B"}
|
|
@@ -1,68 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const common_1 = require("@nestjs/common");
|
|
4
|
-
const axios_1 = require("axios");
|
|
5
4
|
const http_service_1 = require("./http.service");
|
|
6
|
-
|
|
5
|
+
function createAxiosMock() {
|
|
6
|
+
const fn = jest.fn((config) => fn.request(config));
|
|
7
|
+
fn.request = jest.fn((config) => {
|
|
8
|
+
const last = fn.request.mock.results[fn.request.mock.calls.length - 1];
|
|
9
|
+
return last?.value;
|
|
10
|
+
});
|
|
11
|
+
fn.interceptors = {
|
|
12
|
+
request: { use: jest.fn() },
|
|
13
|
+
response: { use: jest.fn() },
|
|
14
|
+
};
|
|
15
|
+
fn.defaults = {};
|
|
16
|
+
fn.getUri = jest.fn(() => '/mock');
|
|
17
|
+
return fn;
|
|
18
|
+
}
|
|
7
19
|
describe('NovoHttpService', () => {
|
|
20
|
+
let axiosMock;
|
|
8
21
|
let service;
|
|
9
|
-
let mockAxiosInstance = {
|
|
10
|
-
interceptors: {
|
|
11
|
-
request: { use: jest.fn() },
|
|
12
|
-
response: { use: jest.fn() },
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
22
|
beforeEach(() => {
|
|
16
23
|
jest.clearAllMocks();
|
|
17
24
|
jest.useFakeTimers();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
request: { use: jest.fn() },
|
|
21
|
-
response: { use: jest.fn() },
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
axios_1.default.create.mockReturnValue(mockAxiosInstance);
|
|
25
|
-
service = new http_service_1.NovoHttpService(mockAxiosInstance);
|
|
25
|
+
axiosMock = createAxiosMock();
|
|
26
|
+
service = new http_service_1.NovoHttpService(axiosMock);
|
|
26
27
|
});
|
|
27
|
-
it('
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
expect(result.
|
|
33
|
-
expect(result.
|
|
34
|
-
expect(result.url).toBe('/test');
|
|
28
|
+
it('register request interceptor with default retry config', () => {
|
|
29
|
+
const interceptor = axiosMock.interceptors.request.use.mock.calls[0][0];
|
|
30
|
+
const cfg = { url: '/x' };
|
|
31
|
+
const result = interceptor(cfg);
|
|
32
|
+
expect(result.__retryCount).toBe(0);
|
|
33
|
+
expect(result.__maxRetries).toBe(2);
|
|
34
|
+
expect(result.__retryDelay).toBe(200);
|
|
35
35
|
});
|
|
36
|
-
it('
|
|
37
|
-
expect(
|
|
36
|
+
it('register response interceptor', () => {
|
|
37
|
+
expect(axiosMock.interceptors.response.use).toHaveBeenCalledTimes(1);
|
|
38
|
+
const [successFn, errorFn] = axiosMock.interceptors.response.use.mock.calls[0];
|
|
39
|
+
expect(typeof successFn).toBe('function');
|
|
40
|
+
expect(typeof errorFn).toBe('function');
|
|
38
41
|
});
|
|
39
|
-
it('retries on 503
|
|
40
|
-
const
|
|
42
|
+
it('retries on 503 response and logs a warning', async () => {
|
|
43
|
+
const requestInterceptor = axiosMock.interceptors.request.use.mock.calls[0][0];
|
|
44
|
+
const errorInterceptor = axiosMock.interceptors.response.use.mock.calls[0][1];
|
|
41
45
|
const warnSpy = jest.spyOn(common_1.Logger.prototype, 'warn').mockImplementation();
|
|
42
|
-
const
|
|
43
|
-
|
|
46
|
+
const config = requestInterceptor({
|
|
47
|
+
url: '/retry',
|
|
48
|
+
__retryDelay: 50,
|
|
49
|
+
});
|
|
44
50
|
const error = {
|
|
45
|
-
config
|
|
46
|
-
|
|
51
|
+
config,
|
|
52
|
+
code: 'ETIMEDOUT',
|
|
53
|
+
response: { status: 503 },
|
|
47
54
|
};
|
|
48
|
-
|
|
55
|
+
axiosMock.request.mockResolvedValueOnce({ data: 'ok' });
|
|
56
|
+
const promise = errorInterceptor(error);
|
|
49
57
|
jest.advanceTimersByTime(50);
|
|
50
|
-
await
|
|
51
|
-
expect(warnSpy).toHaveBeenCalledWith('
|
|
52
|
-
expect(
|
|
58
|
+
const result = await promise;
|
|
59
|
+
expect(warnSpy).toHaveBeenCalledWith('Retrying request (1/2) → /retry');
|
|
60
|
+
expect(axiosMock.request).toHaveBeenCalledTimes(1);
|
|
61
|
+
expect(result.data).toBe('ok');
|
|
53
62
|
});
|
|
54
|
-
it('fails immediately
|
|
55
|
-
const
|
|
56
|
-
const error = { config: undefined
|
|
57
|
-
await expect(
|
|
63
|
+
it('fails immediately when config is missing', async () => {
|
|
64
|
+
const errorInterceptor = axiosMock.interceptors.response.use.mock.calls[0][1];
|
|
65
|
+
const error = { config: undefined };
|
|
66
|
+
await expect(errorInterceptor(error)).rejects.toBe(error);
|
|
58
67
|
});
|
|
59
|
-
it('
|
|
60
|
-
const
|
|
68
|
+
it('does not retry on non-retriable errors', async () => {
|
|
69
|
+
const requestInterceptor = axiosMock.interceptors.request.use.mock.calls[0][0];
|
|
70
|
+
const errorInterceptor = axiosMock.interceptors.response.use.mock.calls[0][1];
|
|
71
|
+
const config = requestInterceptor({
|
|
72
|
+
url: '/fail',
|
|
73
|
+
__retryDelay: 100,
|
|
74
|
+
});
|
|
61
75
|
const error = {
|
|
62
|
-
config
|
|
63
|
-
|
|
76
|
+
config,
|
|
77
|
+
code: 'ECONNRESET',
|
|
78
|
+
response: undefined,
|
|
64
79
|
};
|
|
65
|
-
await expect(
|
|
80
|
+
await expect(errorInterceptor(error)).rejects.toBe(error);
|
|
81
|
+
expect(axiosMock.request).not.toHaveBeenCalled();
|
|
66
82
|
});
|
|
67
83
|
});
|
|
68
84
|
//# sourceMappingURL=http.service.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.service.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/http/http.service.spec.ts"],"names":[],"mappings":";;AAAA,2CAAwC;
|
|
1
|
+
{"version":3,"file":"http.service.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/http/http.service.spec.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AAExC,iDAAiD;AAEjD,SAAS,eAAe;IACtB,MAAM,EAAE,GAAQ,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAExD,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvE,OAAO,IAAI,EAAE,KAAK,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,YAAY,GAAG;QAChB,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;QAC3B,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC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AC;QAC1D,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { UserData } from '@novo-learning/novo-sdk';
|
|
2
2
|
import { Strategy } from 'passport-jwt';
|
|
3
|
-
declare const JwtStrategy_base: new (...args: [
|
|
4
|
-
validate(...args: any[]): unknown;
|
|
5
|
-
};
|
|
3
|
+
declare const JwtStrategy_base: new (...args: any[]) => Strategy;
|
|
6
4
|
export declare class JwtStrategy extends JwtStrategy_base {
|
|
7
5
|
private readonly jwtSecret;
|
|
8
6
|
constructor(jwtSecret: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iso-logger.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/logger/iso-logger.spec.ts"],"names":[],"mappings":";;AAEA,6CAAyC;AAEzC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,aAAyC,CAAC;IAE9C,UAAU,CAAC,GAAG,EAAE;QACd,aAAa,GAAG;YACd,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"iso-logger.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/logger/iso-logger.spec.ts"],"names":[],"mappings":";;AAEA,6CAAyC;AAEzC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,aAAyC,CAAC;IAE9C,UAAU,CAAC,GAAG,EAAE;QACd,aAAa,GAAG;YACd,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;SAC0D,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,aAAa,CAAC,CA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GAAG,EAAE;QAC1E,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,aAAa,CAAC,CAAC;QAE5C,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAE,CAAC,KAAK,EAAE,OAAO,CAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnG,MAAM,CAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,aAAa,CAAC,CAAC;QAE5C,MAAM,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QACjC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,+CAA+C,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novo-learning/service-lib",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "Common components for Novo services",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,12 +17,18 @@
|
|
|
17
17
|
"test:debug": "node --inspect node_modules/.bin/jest --runInBand"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@nestjs/axios": "^3.1.3",
|
|
21
|
+
"@nestjs/cache-manager": "^2.3.0",
|
|
22
|
+
"@nestjs/common": "^10.4.13",
|
|
23
|
+
"@nestjs/config": "^3.3.0",
|
|
24
|
+
"@nestjs/core": "^10.4.13",
|
|
25
|
+
"@nestjs/mongoose": "^10.1.0",
|
|
26
|
+
"@nestjs/passport": "^10.0.3",
|
|
20
27
|
"@novo-learning/novo-sdk": "^0.9.2",
|
|
21
28
|
"axios": "^1.8.4",
|
|
22
29
|
"axios-retry": "^4.5.0",
|
|
23
30
|
"buffer": "^6.0.3",
|
|
24
|
-
"cache-manager": "^4.1.0
|
|
25
|
-
"cacheable": "^2.3.4",
|
|
31
|
+
"cache-manager": "^4.1.0",
|
|
26
32
|
"class-transformer": "^0.5.1",
|
|
27
33
|
"class-validator": "^0.14.3",
|
|
28
34
|
"form-data": "^4.0.0",
|
|
@@ -31,13 +37,13 @@
|
|
|
31
37
|
"passport-jwt": "^4.0.1"
|
|
32
38
|
},
|
|
33
39
|
"peerDependencies": {
|
|
34
|
-
"@nestjs/
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
40
|
+
"@nestjs/common": "^10.4.4 || ^11.0.0",
|
|
41
|
+
"cache-manager": "^4.1.0",
|
|
42
|
+
"class-transformer": "^0.5.1",
|
|
43
|
+
"class-validator": "^0.14.3",
|
|
44
|
+
"form-data": "^4.0.0",
|
|
45
|
+
"passport": "^0.7.0",
|
|
46
|
+
"passport-jwt": "^4.0.1",
|
|
41
47
|
"rxjs": "^7.8.1",
|
|
42
48
|
"typescript": ">=5"
|
|
43
49
|
},
|
|
@@ -46,16 +52,9 @@
|
|
|
46
52
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
47
53
|
"@babel/preset-env": "^7.26.0",
|
|
48
54
|
"@babel/preset-typescript": "^7.26.0",
|
|
49
|
-
"@nestjs/
|
|
50
|
-
"@nestjs/
|
|
51
|
-
"@nestjs/
|
|
52
|
-
"@nestjs/config": "^4.0.0",
|
|
53
|
-
"@nestjs/core": "^11.0.0",
|
|
54
|
-
"@nestjs/microservices": "^11.0.0",
|
|
55
|
-
"@nestjs/mongoose": "^11.0.0",
|
|
56
|
-
"@nestjs/passport": "^11.0.0",
|
|
57
|
-
"@nestjs/platform-express": "^11.0.0",
|
|
58
|
-
"@nestjs/testing": "^11.0.0",
|
|
55
|
+
"@nestjs/microservices": "^10.4.13",
|
|
56
|
+
"@nestjs/platform-express": "^10.4.15",
|
|
57
|
+
"@nestjs/testing": "^10.4.13",
|
|
59
58
|
"@novo-learning/eslint-config": "^0.3.0",
|
|
60
59
|
"@types/cache-manager": "^3.4.3",
|
|
61
60
|
"@types/jest": "^29.5.14",
|
|
@@ -81,4 +80,4 @@
|
|
|
81
80
|
"overrides": {
|
|
82
81
|
"multer": "2.1.1"
|
|
83
82
|
}
|
|
84
|
-
}
|
|
83
|
+
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var ExerciseApiModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ExerciseApiModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const http_1 = require("../../nest/http");
|
|
13
|
-
const exercise_service_1 = require("./exercise.service");
|
|
14
|
-
let ExerciseApiModule = ExerciseApiModule_1 = class ExerciseApiModule {
|
|
15
|
-
static forRoot(exerciseApi) {
|
|
16
|
-
return {
|
|
17
|
-
module: ExerciseApiModule_1,
|
|
18
|
-
providers: [
|
|
19
|
-
{ provide: exercise_service_1.ExerciseService, useFactory: () => new exercise_service_1.ExerciseService(new http_1.NovoHttpService(), exerciseApi) },
|
|
20
|
-
],
|
|
21
|
-
exports: [exercise_service_1.ExerciseService],
|
|
22
|
-
imports: [http_1.NovoHttpModule],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.ExerciseApiModule = ExerciseApiModule;
|
|
27
|
-
exports.ExerciseApiModule = ExerciseApiModule = ExerciseApiModule_1 = __decorate([
|
|
28
|
-
(0, common_1.Module)({})
|
|
29
|
-
], ExerciseApiModule);
|
|
30
|
-
//# sourceMappingURL=exercise-api.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exercise-api.module.js","sourceRoot":"","sources":["../../../../src/modules/clients/exercise-api/exercise-api.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,0CAAkE;AAClE,yDAAqD;AAG9C,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,WAAmB;QAChC,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,kCAAe,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,kCAAe,CAAC,IAAI,sBAAe,EAAE,EAAE,WAAW,CAAC,EAAE;aACxG;YACD,OAAO,EAAE,CAAC,kCAAe,CAAC;YAC1B,OAAO,EAAE,CAAC,qBAAc,CAAC;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AAXY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CAW7B"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Exercise, ExerciseDescriptorDtoV1, ExerciseType, LanguageCode } from '@novo-learning/novo-sdk';
|
|
2
|
-
import { NovoHttpService } from '../../nest/http';
|
|
3
|
-
export type ExerciseFilter = {
|
|
4
|
-
languageCode?: LanguageCode;
|
|
5
|
-
exerciseType?: ExerciseType;
|
|
6
|
-
customFilter?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const EXERCISE_API = "EXERCISE_API";
|
|
9
|
-
export declare class ExerciseService {
|
|
10
|
-
private readonly httpService;
|
|
11
|
-
private readonly apiUrl;
|
|
12
|
-
private readonly api;
|
|
13
|
-
constructor(httpService: NovoHttpService, apiUrl: string);
|
|
14
|
-
getExercises({ languageCode, exerciseType, customFilter }: ExerciseFilter, accessToken: string): Promise<ExerciseDescriptorDtoV1[] | {
|
|
15
|
-
error: string;
|
|
16
|
-
}>;
|
|
17
|
-
getExercise(id: string, accessToken: string): Promise<Exercise | {
|
|
18
|
-
error: string;
|
|
19
|
-
}>;
|
|
20
|
-
saveExercise(exercise: Exercise, accessToken: string): Promise<Exercise | {
|
|
21
|
-
error: string;
|
|
22
|
-
}>;
|
|
23
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var ExerciseService_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ExerciseService = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const novo_sdk_1 = require("@novo-learning/novo-sdk");
|
|
19
|
-
const http_1 = require("../../nest/http");
|
|
20
|
-
let ExerciseService = ExerciseService_1 = class ExerciseService {
|
|
21
|
-
constructor(httpService, apiUrl) {
|
|
22
|
-
this.httpService = httpService;
|
|
23
|
-
this.apiUrl = apiUrl;
|
|
24
|
-
const url = this.apiUrl.includes('://') ? this.apiUrl : `http://${this.apiUrl}`;
|
|
25
|
-
this.api = new novo_sdk_1.ExerciseApi(undefined, url, httpService.axiosRef);
|
|
26
|
-
}
|
|
27
|
-
async getExercises({ languageCode, exerciseType, customFilter }, accessToken) {
|
|
28
|
-
try {
|
|
29
|
-
const { data: exercises } = await this.api.getExerciseListV1(customFilter, exerciseType, languageCode, {
|
|
30
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
31
|
-
});
|
|
32
|
-
return exercises;
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
const message = err.response?.data?.message;
|
|
36
|
-
return { error: `${ExerciseService_1.name}: ${message || err.message || err.response?.statusText || err.code}` };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async getExercise(id, accessToken) {
|
|
40
|
-
try {
|
|
41
|
-
const { data: exercise } = await this.api.getExerciseV1(id, {
|
|
42
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
...exercise,
|
|
46
|
-
publisherId: '',
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
return { error: `${ExerciseService_1.name}: ${err.code || err.response?.statusText}` };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async saveExercise(exercise, accessToken) {
|
|
54
|
-
try {
|
|
55
|
-
if (exercise.id === undefined) {
|
|
56
|
-
const { data: responseExercise } = await this.api.createExerciseV1(exercise, {
|
|
57
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
...responseExercise,
|
|
61
|
-
publisherId: '',
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
const { data: responseExercise } = await this.api.replaceExerciseV1(exercise.id, exercise);
|
|
66
|
-
return {
|
|
67
|
-
...responseExercise,
|
|
68
|
-
publisherId: '',
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
return { error: `${ExerciseService_1.name}: ${err.code || err.response?.statusText}` };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
exports.ExerciseService = ExerciseService;
|
|
78
|
-
exports.ExerciseService = ExerciseService = ExerciseService_1 = __decorate([
|
|
79
|
-
(0, common_1.Injectable)(),
|
|
80
|
-
__param(1, (0, common_1.Inject)(exports.EXERCISE_API)),
|
|
81
|
-
__metadata("design:paramtypes", [http_1.NovoHttpService, String])
|
|
82
|
-
], ExerciseService);
|
|
83
|
-
//# sourceMappingURL=exercise.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exercise.service.js","sourceRoot":"","sources":["../../../../src/modules/clients/exercise-api/exercise.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,sDAAqH;AACrH,0CAAkD;AAO3C,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YAA6B,WAA4B,EAAyC,MAAc;QAAnF,gBAAW,GAAX,WAAW,CAAiB;QAAyC,WAA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}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.InvalidRequestFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const suppressedPatterns = ['too many parameters', 'entity too large', 'unsupported content encoding'];
|
|
12
|
-
let InvalidRequestFilter = class InvalidRequestFilter {
|
|
13
|
-
catch(exception, host) {
|
|
14
|
-
if (exception instanceof Error) {
|
|
15
|
-
const message = exception.message;
|
|
16
|
-
const lower = message.toLowerCase();
|
|
17
|
-
if (suppressedPatterns.some((p) => lower.includes(p))) {
|
|
18
|
-
const ctx = host.switchToHttp();
|
|
19
|
-
const response = ctx.getResponse();
|
|
20
|
-
return response.status(400).json({
|
|
21
|
-
error: 'Invalid request',
|
|
22
|
-
message: 'The request could not be processed: ' + message,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
throw exception;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.InvalidRequestFilter = InvalidRequestFilter;
|
|
30
|
-
exports.InvalidRequestFilter = InvalidRequestFilter = __decorate([
|
|
31
|
-
(0, common_1.Catch)()
|
|
32
|
-
], InvalidRequestFilter);
|
|
33
|
-
//# sourceMappingURL=invalid-request.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-request.filter.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/invalid-request.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AAEvE,MAAM,kBAAkB,GAAG,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,8BAA8B,CAAU,CAAC;AAMzG,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,KAAK,CAAC,SAAkB,EAAE,IAAmB;QAC3C,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACpC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;gBAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;gBACnC,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBAC/B,KAAK,EAAE,iBAAiB;oBACxB,OAAO,EAAE,sCAAsC,GAAG,OAAO;iBAC1D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,MAAM,SAAS,CAAC;IAClB,CAAC;CACF,CAAA;AAhBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,cAAK,GAAE;GACK,oBAAoB,CAgBhC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const invalid_request_filter_1 = require("./invalid-request.filter");
|
|
4
|
-
describe('InvalidRequestFilter', () => {
|
|
5
|
-
const filter = new invalid_request_filter_1.InvalidRequestFilter();
|
|
6
|
-
function createMockHost() {
|
|
7
|
-
const json = jest.fn();
|
|
8
|
-
const status = jest.fn(() => ({ json }));
|
|
9
|
-
const getResponse = jest.fn(() => ({ status }));
|
|
10
|
-
const host = {
|
|
11
|
-
switchToHttp: (() => ({
|
|
12
|
-
getResponse,
|
|
13
|
-
})),
|
|
14
|
-
getArgs: (() => []),
|
|
15
|
-
getArgByIndex: (() => undefined),
|
|
16
|
-
switchToRpc: () => ({}),
|
|
17
|
-
switchToWs: () => ({}),
|
|
18
|
-
getType: (() => 'http'),
|
|
19
|
-
};
|
|
20
|
-
return { host, status, json };
|
|
21
|
-
}
|
|
22
|
-
it('should intercept the unsupported encoding error and return 400', () => {
|
|
23
|
-
const { host, status, json } = createMockHost();
|
|
24
|
-
const error = new Error('unsupported content encoding "chunked"');
|
|
25
|
-
filter.catch(error, host);
|
|
26
|
-
expect(status).toHaveBeenCalledWith(400);
|
|
27
|
-
expect(json).toHaveBeenCalledWith({
|
|
28
|
-
error: 'Invalid request',
|
|
29
|
-
message: 'The request could not be processed: unsupported content encoding "chunked"',
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
it('should rethrow other errors', () => {
|
|
33
|
-
const { host } = createMockHost();
|
|
34
|
-
const error = new Error('some other error');
|
|
35
|
-
expect(() => filter.catch(error, host)).toThrow(error);
|
|
36
|
-
});
|
|
37
|
-
it('should rethrow non-Error exceptions', () => {
|
|
38
|
-
const { host } = createMockHost();
|
|
39
|
-
const value = { foo: 'bar' };
|
|
40
|
-
try {
|
|
41
|
-
filter.catch(value, host);
|
|
42
|
-
fail('Expected exception to be thrown');
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
expect(err).toBe(value);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=invalid-request.filter.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-request.filter.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/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M,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC;YAChC,KAAK,EAAE,iBAAiB;YACxB,OAAO,EAAE,4EAA4E;SACtF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE5C,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC1B,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RequestAbortedFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let RequestAbortedFilter = class RequestAbortedFilter {
|
|
12
|
-
catch(exception, _) {
|
|
13
|
-
if (exception instanceof Error) {
|
|
14
|
-
const message = exception.message.toLowerCase();
|
|
15
|
-
if (message.includes('request aborted')) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
throw exception;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.RequestAbortedFilter = RequestAbortedFilter;
|
|
23
|
-
exports.RequestAbortedFilter = RequestAbortedFilter = __decorate([
|
|
24
|
-
(0, common_1.Catch)()
|
|
25
|
-
], RequestAbortedFilter);
|
|
26
|
-
//# sourceMappingURL=request-aborted.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-aborted.filter.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/request-aborted.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AAMhE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,KAAK,CAAC,SAAkB,EAAE,CAAgB;QACxC,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACxC,OAAO;YACT,CAAC;QACH,CAAC;QACD,MAAM,SAAS,CAAC;IAClB,CAAC;CACF,CAAA;AAVY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,cAAK,GAAE;GACK,oBAAoB,CAUhC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const request_aborted_filter_1 = require("./request-aborted.filter");
|
|
4
|
-
describe('RequestAbortedFilter', () => {
|
|
5
|
-
const filter = new request_aborted_filter_1.RequestAbortedFilter();
|
|
6
|
-
const host = {};
|
|
7
|
-
it('should intercept the request aborted error', () => {
|
|
8
|
-
const error = new Error('request aborted');
|
|
9
|
-
expect(() => filter.catch(error, host)).not.toThrow();
|
|
10
|
-
});
|
|
11
|
-
it('should rethrow other errors', () => {
|
|
12
|
-
const error = new Error('some other error');
|
|
13
|
-
expect(() => filter.catch(error, host)).toThrow(error);
|
|
14
|
-
});
|
|
15
|
-
it('should rethrow non-Error exceptions', () => {
|
|
16
|
-
const value = { foo: 'bar' };
|
|
17
|
-
try {
|
|
18
|
-
filter.catch(value, host);
|
|
19
|
-
fail('Expected exception to be thrown');
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
expect(err).toBe(value);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=request-aborted.filter.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-aborted.filter.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/request-aborted.filter.spec.ts"],"names":[],"mappings":";;AACA,qEAAgE;AAEhE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,MAAM,GAAG,IAAI,6CAAoB,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAmB,CAAC;IAEjC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC5C,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC1B,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.UnsupportedEncodingFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let UnsupportedEncodingFilter = class UnsupportedEncodingFilter {
|
|
12
|
-
catch(exception, host) {
|
|
13
|
-
if (exception instanceof Error) {
|
|
14
|
-
const message = exception?.message || '';
|
|
15
|
-
if (message.includes('unsupported content encoding')) {
|
|
16
|
-
const ctx = host.switchToHttp();
|
|
17
|
-
const response = ctx.getResponse();
|
|
18
|
-
return response.status(400).json({
|
|
19
|
-
error: 'Invalid content encoding',
|
|
20
|
-
message: 'The request used an unsupported content encoding.',
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
throw exception;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
exports.UnsupportedEncodingFilter = UnsupportedEncodingFilter;
|
|
28
|
-
exports.UnsupportedEncodingFilter = UnsupportedEncodingFilter = __decorate([
|
|
29
|
-
(0, common_1.Catch)()
|
|
30
|
-
], UnsupportedEncodingFilter);
|
|
31
|
-
//# sourceMappingURL=unsupported-encoding.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-encoding.filter.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/unsupported-encoding.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AAMhE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,KAAK,CAAC,SAAkB,EAAE,IAAmB;QAC3C,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,SAAS,EAAE,OAAO,IAAI,EAAE,CAAC;YACzC,IAAI,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,CAAC;gBACrD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;gBAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;gBACnC,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBAC/B,KAAK,EAAE,0BAA0B;oBACjC,OAAO,EAAE,mDAAmD;iBAC7D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,MAAM,SAAS,CAAC;IAClB,CAAC;CACF,CAAA;AAfY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,cAAK,GAAE;GACK,yBAAyB,CAerC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const unsupported_encoding_filter_1 = require("./unsupported-encoding.filter");
|
|
4
|
-
describe('UnsupportedEncodingFilter', () => {
|
|
5
|
-
const filter = new unsupported_encoding_filter_1.UnsupportedEncodingFilter();
|
|
6
|
-
function createMockHost() {
|
|
7
|
-
const json = jest.fn();
|
|
8
|
-
const status = jest.fn(() => ({ json }));
|
|
9
|
-
const getResponse = jest.fn(() => ({ status }));
|
|
10
|
-
const host = {
|
|
11
|
-
switchToHttp: (() => ({
|
|
12
|
-
getResponse,
|
|
13
|
-
})),
|
|
14
|
-
getArgs: (() => []),
|
|
15
|
-
getArgByIndex: (() => undefined),
|
|
16
|
-
switchToRpc: () => ({}),
|
|
17
|
-
switchToWs: () => ({}),
|
|
18
|
-
getType: (() => 'http'),
|
|
19
|
-
};
|
|
20
|
-
return { host, status, json };
|
|
21
|
-
}
|
|
22
|
-
it('should intercept the unsupported encoding error and return 400', () => {
|
|
23
|
-
const { host, status, json } = createMockHost();
|
|
24
|
-
const error = new Error('unsupported content encoding "chunked"');
|
|
25
|
-
filter.catch(error, host);
|
|
26
|
-
expect(status).toHaveBeenCalledWith(400);
|
|
27
|
-
expect(json).toHaveBeenCalledWith({
|
|
28
|
-
error: 'Invalid content encoding',
|
|
29
|
-
message: 'The request used an unsupported content encoding.',
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
it('should rethrow other errors', () => {
|
|
33
|
-
const { host } = createMockHost();
|
|
34
|
-
const error = new Error('some other error');
|
|
35
|
-
expect(() => filter.catch(error, host)).toThrow(error);
|
|
36
|
-
});
|
|
37
|
-
it('should rethrow non-Error exceptions', () => {
|
|
38
|
-
const { host } = createMockHost();
|
|
39
|
-
const value = { foo: 'bar' };
|
|
40
|
-
try {
|
|
41
|
-
filter.catch(value, host);
|
|
42
|
-
fail('Expected exception to be thrown');
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
expect(err).toBe(value);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=unsupported-encoding.filter.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-encoding.filter.spec.js","sourceRoot":"","sources":["../../../../src/modules/nest/exceptions/unsupported-encoding.filter.spec.ts"],"names":[],"mappings":";;AAEA,+EAA0E;AAE1E,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,MAAM,MAAM,GAAG,IAAI,uDAAyB,EAAE,CAAC;IAE/C,SAAS,cAAc;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAEhD,MAAM,IAAI,GAAkB;YAC1B,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpB,WAAW;aACZ,CAAC,CAA6C;YAC/C,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAA6B;YAC/C,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAmC;YAClE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAuB,CAAA;YAC3C,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAA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