@biorate/nestjs-tools 1.138.2 → 1.140.0
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/.nyc_output/399d2826-7070-4544-97a0-f9151f85b7c7.json +1 -0
- package/.nyc_output/processinfo/399d2826-7070-4544-97a0-f9151f85b7c7.json +1 -0
- package/.nyc_output/processinfo/f8c603e3-dd03-4f6d-bde3-8f646414620e.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +11 -0
- package/coverage/lcov-report/index.html +199 -34
- package/coverage/lcov-report/interfaces/file:/www/biorate/core/packages/@biorate/nestjs-tools/interfaces/index.html +116 -0
- package/coverage/lcov-report/interfaces/file:/www/biorate/core/packages/@biorate/nestjs-tools/interfaces/index.ts.html +118 -0
- package/coverage/lcov-report/interfaces/ports/file:/www/biorate/core/packages/@biorate/nestjs-tools/interfaces/ports/index.html +116 -0
- package/coverage/lcov-report/interfaces/ports/file:/www/biorate/core/packages/@biorate/nestjs-tools/interfaces/ports/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/index.html +116 -0
- package/coverage/lcov-report/src/app/application/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/ports/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/ports/index.html +116 -0
- package/coverage/lcov-report/src/app/application/ports/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/ports/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/client/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/client/get-locale.use-case.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/client/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/client/index.html +146 -0
- package/coverage/lcov-report/src/app/application/service/client/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/client/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/client/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/client/set-locale.use-case.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/index.html +116 -0
- package/coverage/lcov-report/src/app/application/service/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/metrics/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/metrics/get-metrics.use-case.ts.html +118 -0
- package/coverage/lcov-report/src/app/application/service/metrics/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/metrics/index.html +131 -0
- package/coverage/lcov-report/src/app/application/service/metrics/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/application/service/metrics/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/index.html +116 -0
- package/coverage/lcov-report/src/app/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/adapters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/adapters/client.repository.adapter.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/adapters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/adapters/index.html +146 -0
- package/coverage/lcov-report/src/app/infrastructure/adapters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/adapters/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/adapters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/adapters/metrics.repository.adapter.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/dto/index.html +131 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/dto/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/dto/locales.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/client.controller.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/index.html +161 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/index.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/metrics.controller.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/controllers/probe.controller.ts.html +118 -0
- package/coverage/lcov-report/src/app/infrastructure/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/index.html +116 -0
- package/coverage/lcov-report/src/app/infrastructure/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/app/infrastructure/index.ts.html +118 -0
- package/coverage/lcov-report/src/decorators/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/decorators/auth.ts.html +1 -1
- package/coverage/lcov-report/src/decorators/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/decorators/index.html +1 -1
- package/coverage/lcov-report/src/decorators/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/decorators/index.ts.html +1 -1
- package/coverage/lcov-report/src/decorators/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/decorators/roles.ts.html +1 -1
- package/coverage/lcov-report/src/enums/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/enums/index.html +1 -1
- package/coverage/lcov-report/src/enums/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/enums/index.ts.html +1 -1
- package/coverage/lcov-report/src/enums/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/enums/user.ts.html +1 -1
- package/coverage/lcov-report/src/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/errors.ts.html +6 -6
- package/coverage/lcov-report/src/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/index.html +15 -15
- package/coverage/lcov-report/src/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/index.ts.html +3 -3
- package/coverage/lcov-report/src/filters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/filters/all-exception-filter.ts.html +5 -5
- package/coverage/lcov-report/src/filters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/filters/index.html +10 -10
- package/coverage/lcov-report/src/filters/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/filters/index.ts.html +1 -1
- package/coverage/lcov-report/src/http/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/controllers/index.html +1 -1
- package/coverage/lcov-report/src/http/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/controllers/index.ts.html +1 -1
- package/coverage/lcov-report/src/http/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/controllers/locales.ts.html +1 -1
- package/coverage/lcov-report/src/http/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/controllers/metrics.ts.html +1 -1
- package/coverage/lcov-report/src/http/controllers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/controllers/probe.ts.html +1 -1
- package/coverage/lcov-report/src/http/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/dto/index.html +1 -1
- package/coverage/lcov-report/src/http/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/dto/index.ts.html +1 -1
- package/coverage/lcov-report/src/http/dto/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/dto/locales.ts.html +1 -1
- package/coverage/lcov-report/src/http/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/index.html +1 -1
- package/coverage/lcov-report/src/http/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/http/index.ts.html +1 -1
- package/coverage/lcov-report/src/interceptors/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/interceptors/index.html +25 -10
- package/coverage/lcov-report/src/interceptors/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/interceptors/index.ts.html +3 -3
- package/coverage/lcov-report/src/interceptors/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/interceptors/routes-interceptor.ts.html +1 -1
- package/coverage/lcov-report/src/interceptors/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/interceptors/tracing-interceptor.ts.html +118 -0
- package/coverage/lcov-report/src/middlewares/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/middlewares/index.html +1 -1
- package/coverage/lcov-report/src/middlewares/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/middlewares/index.ts.html +1 -1
- package/coverage/lcov-report/src/middlewares/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/middlewares/proxy-middleware.ts.html +1 -1
- package/coverage/lcov-report/src/middlewares/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/middlewares/request-count-middleware.ts.html +1 -1
- package/coverage/lcov-report/src/middlewares/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/middlewares/response-time-middleware.ts.html +1 -1
- package/coverage/lcov-report/src/providers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/providers/auth.ts.html +1 -1
- package/coverage/lcov-report/src/providers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/providers/index.html +1 -1
- package/coverage/lcov-report/src/providers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/providers/index.ts.html +1 -1
- package/coverage/lcov-report/src/providers/file:/www/biorate/core/packages/@biorate/nestjs-tools/src/providers/roles.ts.html +1 -1
- package/coverage/lcov.info +516 -97
- package/dist/src/interceptors/index.js +1 -0
- package/dist/src/interceptors/index.js.map +1 -1
- package/dist/src/interceptors/tracing-interceptor.js +71 -0
- package/dist/src/interceptors/tracing-interceptor.js.map +1 -0
- package/dist/src/middlewares/response-time-middleware.js +1 -1
- package/dist/src/middlewares/response-time-middleware.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/index.d.ts +4 -0
- package/package.json +5 -3
- package/src/interceptors/index.ts +1 -0
- package/src/interceptors/tracing-interceptor.ts +66 -0
- package/src/middlewares/response-time-middleware.ts +1 -1
- package/tests/__snapshots__/index.spec.ts.snap +2 -0
- package/tests/index.spec.ts +3 -0
- package/.nyc_output/ef63833e-f8c0-433c-900b-5fb4c26740a5.json +0 -1
- package/.nyc_output/processinfo/2ce61529-0134-4bc1-8da5-d78f4a4162f3.json +0 -1
- package/.nyc_output/processinfo/ef63833e-f8c0-433c-900b-5fb4c26740a5.json +0 -1
- /package/.nyc_output/{2ce61529-0134-4bc1-8da5-d78f4a4162f3.json → f8c603e3-dd03-4f6d-bde3-8f646414620e.json} +0 -0
package/index.d.ts
CHANGED
|
@@ -50,6 +50,10 @@ declare module '@biorate/nestjs-tools' {
|
|
|
50
50
|
public intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
export class TracingInterceptor implements NestInterceptor {
|
|
54
|
+
public intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
export class ProxyPrometheusMiddleware {
|
|
54
58
|
public static create(options?: Options): RequestHandler;
|
|
55
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biorate/nestjs-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.140.0",
|
|
4
4
|
"description": "NestJS tools",
|
|
5
5
|
"main": "dist",
|
|
6
6
|
"scripts": {
|
|
@@ -29,18 +29,20 @@
|
|
|
29
29
|
"http-proxy": ">=1.18.1",
|
|
30
30
|
"http-proxy-middleware": "=2.0.6",
|
|
31
31
|
"lodash": ">=4.17.21",
|
|
32
|
+
"rxjs": ">=7.8.2",
|
|
32
33
|
"ws": ">=8.18.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@biorate/axios": "1.
|
|
36
|
+
"@biorate/axios": "1.139.0",
|
|
36
37
|
"@biorate/config": "1.120.0",
|
|
37
38
|
"@biorate/errors": "1.102.0",
|
|
38
39
|
"@biorate/inversion": "1.120.0",
|
|
40
|
+
"@biorate/opentelemetry": "1.140.0",
|
|
39
41
|
"@biorate/prometheus": "1.120.0",
|
|
40
42
|
"@biorate/tools": "1.102.1",
|
|
41
43
|
"http-proxy": "1.18.1",
|
|
42
44
|
"http-proxy-middleware": "2.0.6",
|
|
43
45
|
"on-headers": "1.0.2"
|
|
44
46
|
},
|
|
45
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b25d59cffea065310fdab24a5aba05b35b0e11ba"
|
|
46
48
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { tap } from 'rxjs';
|
|
2
|
+
import { trace, Span } from '@biorate/opentelemetry';
|
|
3
|
+
import {
|
|
4
|
+
Injectable,
|
|
5
|
+
NestInterceptor,
|
|
6
|
+
ExecutionContext,
|
|
7
|
+
CallHandler,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { inject, Types } from '@biorate/inversion';
|
|
10
|
+
import { IConfig } from '@biorate/config';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class TracingInterceptor implements NestInterceptor {
|
|
14
|
+
@inject(Types.Config) protected readonly config: IConfig;
|
|
15
|
+
|
|
16
|
+
protected stringify(data: unknown) {
|
|
17
|
+
return typeof data === 'object' ? JSON.stringify(data) : String(data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected excluded(url: string) {
|
|
21
|
+
const excluded = this.config.get<(string | RegExp)[]>(
|
|
22
|
+
'TracingInterceptor.excluded',
|
|
23
|
+
[],
|
|
24
|
+
);
|
|
25
|
+
for (const item of excluded) {
|
|
26
|
+
if (typeof item === 'string' && url.startsWith(item)) return true;
|
|
27
|
+
if (item instanceof RegExp && item.test(url)) return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected http(span: Span, context: ExecutionContext, next: CallHandler) {
|
|
33
|
+
const host = context.switchToHttp();
|
|
34
|
+
const req = host.getRequest();
|
|
35
|
+
const res = host.getResponse();
|
|
36
|
+
if (this.excluded(req.url)) return next.handle();
|
|
37
|
+
return next.handle().pipe(
|
|
38
|
+
tap((data) => {
|
|
39
|
+
span.setAttribute('request.url', this.stringify(req.url));
|
|
40
|
+
span.setAttribute('request.body', this.stringify(req.body));
|
|
41
|
+
span.setAttribute('request.headers', this.stringify(req.headers));
|
|
42
|
+
span.setAttribute('request.method', this.stringify(req.method));
|
|
43
|
+
span.setAttribute('request.params', this.stringify(req.params));
|
|
44
|
+
span.setAttribute('request.query', this.stringify(req.query));
|
|
45
|
+
span.setAttribute('response.headers', this.stringify(res.headers));
|
|
46
|
+
span.setAttribute('response.statusCode', this.stringify(res.statusCode));
|
|
47
|
+
span.setAttribute('response.data', this.stringify(data));
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected ws(span: Span, context: ExecutionContext, next: CallHandler) {
|
|
53
|
+
return next.handle();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected rpc(span: Span, context: ExecutionContext, next: CallHandler) {
|
|
57
|
+
return next.handle();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public intercept(context: ExecutionContext, next: CallHandler) {
|
|
61
|
+
const span = trace.getActiveSpan();
|
|
62
|
+
if (!span) return next.handle();
|
|
63
|
+
const type = context.getType();
|
|
64
|
+
return this[type](span, context, next);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -5,8 +5,8 @@ import { inject, Types } from '@biorate/inversion';
|
|
|
5
5
|
import { IConfig } from '@biorate/config';
|
|
6
6
|
import { histogram, Histogram } from '@biorate/prometheus';
|
|
7
7
|
import { Request, Response, NextFunction } from 'express';
|
|
8
|
-
import { RoutesInterceptor } from '../interceptors';
|
|
9
8
|
import { time } from '@biorate/tools';
|
|
9
|
+
import { RoutesInterceptor } from '../interceptors';
|
|
10
10
|
|
|
11
11
|
@Injectable()
|
|
12
12
|
export class ResponseTimeMiddleware implements NestMiddleware {
|
|
@@ -30,6 +30,8 @@ exports[`nestjs-tools RolesGuardProvider 1`] = `[Function]`;
|
|
|
30
30
|
|
|
31
31
|
exports[`nestjs-tools RoutesInterceptor 1`] = `[Function]`;
|
|
32
32
|
|
|
33
|
+
exports[`nestjs-tools TracingInterceptor 1`] = `[Function]`;
|
|
34
|
+
|
|
33
35
|
exports[`nestjs-tools UnsupportedProtocolError 1`] = `[Function]`;
|
|
34
36
|
|
|
35
37
|
exports[`nestjs-tools UserRoles 1`] = `
|
package/tests/index.spec.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
PostLocalesDTO,
|
|
18
18
|
GetLocalesDTO,
|
|
19
19
|
UnsupportedProtocolError,
|
|
20
|
+
TracingInterceptor,
|
|
20
21
|
ROLES_KEY,
|
|
21
22
|
} from '../src';
|
|
22
23
|
|
|
@@ -57,5 +58,7 @@ describe('nestjs-tools', () => {
|
|
|
57
58
|
it('UnsupportedProtocolError', () =>
|
|
58
59
|
expect(UnsupportedProtocolError).toMatchSnapshot());
|
|
59
60
|
|
|
61
|
+
it('TracingInterceptor', () => expect(TracingInterceptor).toMatchSnapshot());
|
|
62
|
+
|
|
60
63
|
it('ROLES_KEY', () => expect(ROLES_KEY).toMatchSnapshot());
|
|
61
64
|
});
|