@nathapp/nestjs-observability 3.3.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/.eslintrc.js +8 -0
- package/.nax/features/nestjs-observability/.nax-acceptance.test.ts +797 -0
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +15 -0
- package/README.md +71 -0
- package/dist/constant/index.d.ts +1 -0
- package/dist/constant/index.js +18 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/observability.constants.d.ts +7 -0
- package/dist/constant/observability.constants.js +13 -0
- package/dist/constant/observability.constants.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/index.d.ts +2 -0
- package/dist/interface/index.js +19 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/observability-module-options.interface.d.ts +26 -0
- package/dist/interface/observability-module-options.interface.js +3 -0
- package/dist/interface/observability-module-options.interface.js.map +1 -0
- package/dist/interface/tracing-bootstrap-options.interface.d.ts +7 -0
- package/dist/interface/tracing-bootstrap-options.interface.js +3 -0
- package/dist/interface/tracing-bootstrap-options.interface.js.map +1 -0
- package/dist/metrics/http-metrics.interceptor.d.ts +16 -0
- package/dist/metrics/http-metrics.interceptor.js +123 -0
- package/dist/metrics/http-metrics.interceptor.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +11 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/metrics.providers.d.ts +6 -0
- package/dist/metrics/metrics.providers.js +81 -0
- package/dist/metrics/metrics.providers.js.map +1 -0
- package/dist/module/index.d.ts +1 -0
- package/dist/module/index.js +18 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/observability.module.d.ts +8 -0
- package/dist/module/observability.module.js +172 -0
- package/dist/module/observability.module.js.map +1 -0
- package/dist/tracing/index.d.ts +4 -0
- package/dist/tracing/index.js +21 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/init-tracing.d.ts +7 -0
- package/dist/tracing/init-tracing.js +72 -0
- package/dist/tracing/init-tracing.js.map +1 -0
- package/dist/tracing/shutdown.d.ts +2 -0
- package/dist/tracing/shutdown.js +19 -0
- package/dist/tracing/shutdown.js.map +1 -0
- package/dist/tracing/trace-context.interceptor.d.ts +8 -0
- package/dist/tracing/trace-context.interceptor.js +44 -0
- package/dist/tracing/trace-context.interceptor.js.map +1 -0
- package/dist/tracing/trace-internal.d.ts +3 -0
- package/dist/tracing/trace-internal.js +19 -0
- package/dist/tracing/trace-internal.js.map +1 -0
- package/dist/tracing/trace.decorator.d.ts +1 -0
- package/dist/tracing/trace.decorator.js +55 -0
- package/dist/tracing/trace.decorator.js.map +1 -0
- package/dist/tracing/trace.service.d.ts +5 -0
- package/dist/tracing/trace.service.js +55 -0
- package/dist/tracing/trace.service.js.map +1 -0
- package/lib/constant/index.ts +1 -0
- package/lib/constant/observability.constants.ts +21 -0
- package/lib/index.ts +17 -0
- package/lib/interface/index.ts +2 -0
- package/lib/interface/observability-module-options.interface.ts +47 -0
- package/lib/interface/tracing-bootstrap-options.interface.ts +17 -0
- package/lib/metrics/http-metrics.interceptor.ts +174 -0
- package/lib/metrics/index.ts +7 -0
- package/lib/metrics/metrics.providers.ts +134 -0
- package/lib/module/index.ts +1 -0
- package/lib/module/observability.module.ts +236 -0
- package/lib/tracing/index.ts +4 -0
- package/lib/tracing/init-tracing.ts +92 -0
- package/lib/tracing/shutdown.ts +28 -0
- package/lib/tracing/trace-context.interceptor.ts +42 -0
- package/lib/tracing/trace-internal.ts +19 -0
- package/lib/tracing/trace.decorator.ts +63 -0
- package/lib/tracing/trace.service.ts +48 -0
- package/package.json +60 -0
- package/test/jest-nax.json +27 -0
- package/test/jest-test.json +28 -0
- package/test/metrics/http-metrics.interceptor.spec.ts +453 -0
- package/test/metrics/metrics.providers.spec.ts +97 -0
- package/test/module/observability.module.spec.ts +229 -0
- package/test/tracing/build-node-sdk.spec.ts +224 -0
- package/test/tracing/init-tracing.idempotency.spec.ts +64 -0
- package/test/tracing/init-tracing.shutdown.spec.ts +88 -0
- package/test/tracing/shutdown.spec.ts +109 -0
- package/test/tracing/trace-context.interceptor.spec.ts +221 -0
- package/test/tracing/trace.decorator.spec.ts +153 -0
- package/test/tracing/trace.service.spec.ts +205 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Instrumentation } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
3
|
+
import type { Sampler } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import {
|
|
5
|
+
AlwaysOffSampler,
|
|
6
|
+
AlwaysOnSampler,
|
|
7
|
+
TraceIdRatioBasedSampler,
|
|
8
|
+
} from '@opentelemetry/sdk-trace-base';
|
|
9
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
10
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
11
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
12
|
+
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
13
|
+
import type { TracingBootstrapOptions } from '../interface';
|
|
14
|
+
import { registerShutdown } from './shutdown';
|
|
15
|
+
|
|
16
|
+
export type { TracingBootstrapOptions };
|
|
17
|
+
|
|
18
|
+
export { registerShutdown } from './shutdown';
|
|
19
|
+
|
|
20
|
+
const chooseSampler = (ratio: number | undefined): Sampler => {
|
|
21
|
+
if (ratio === undefined) return new AlwaysOnSampler();
|
|
22
|
+
if (!Number.isFinite(ratio) || ratio < 0 || ratio > 1) {
|
|
23
|
+
throw new Error(`samplingRatio must be a finite number in [0, 1], received ${ratio}`);
|
|
24
|
+
}
|
|
25
|
+
if (ratio === 0) return new AlwaysOffSampler();
|
|
26
|
+
if (ratio === 1) return new AlwaysOnSampler();
|
|
27
|
+
return new TraceIdRatioBasedSampler(ratio);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const chooseTraceExporter = (
|
|
31
|
+
opts: TracingBootstrapOptions,
|
|
32
|
+
): ConsoleSpanExporter | OTLPTraceExporter | undefined => {
|
|
33
|
+
const exporter = opts.exporter ?? 'otlp';
|
|
34
|
+
switch (exporter) {
|
|
35
|
+
case 'console':
|
|
36
|
+
return new ConsoleSpanExporter();
|
|
37
|
+
case 'otlp':
|
|
38
|
+
return new OTLPTraceExporter({ url: opts.otlpUrl });
|
|
39
|
+
case 'none':
|
|
40
|
+
return undefined;
|
|
41
|
+
default: {
|
|
42
|
+
const exhaustive: never = exporter;
|
|
43
|
+
throw new Error(`unknown exporter ${String(exhaustive)}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const buildInstrumentations = (opts: TracingBootstrapOptions): unknown[] => {
|
|
49
|
+
if (opts.instrumentations !== undefined) return opts.instrumentations;
|
|
50
|
+
return getNodeAutoInstrumentations();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Default SDK factory: builds a configured OpenTelemetry {@link NodeSDK} from the
|
|
55
|
+
* supplied bootstrap options. Exposed so consumers (and tests) can swap it out via
|
|
56
|
+
* {@link initTracing}'s optional `sdkFactory` argument.
|
|
57
|
+
*/
|
|
58
|
+
export function buildNodeSdk(opts: TracingBootstrapOptions): NodeSDK {
|
|
59
|
+
const resource = resourceFromAttributes({ 'service.name': opts.serviceName });
|
|
60
|
+
return new NodeSDK({
|
|
61
|
+
resource,
|
|
62
|
+
sampler: chooseSampler(opts.samplingRatio),
|
|
63
|
+
traceExporter: chooseTraceExporter(opts),
|
|
64
|
+
instrumentations: buildInstrumentations(opts) as Instrumentation[],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type SdkLike = Pick<NodeSDK, 'start' | 'shutdown'>;
|
|
69
|
+
|
|
70
|
+
let started = false;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Starts the OpenTelemetry NodeSDK. MUST be called as the very first statements of
|
|
74
|
+
* `main.ts`, before any `@nestjs/*` or `AppModule` import, so auto-instrumentation can
|
|
75
|
+
* patch modules at require time. Idempotent (a second call is a no-op) and best-effort
|
|
76
|
+
* (exporter/start failures are warn-logged, never thrown) — app boot always proceeds.
|
|
77
|
+
*/
|
|
78
|
+
export function initTracing(
|
|
79
|
+
opts: TracingBootstrapOptions,
|
|
80
|
+
sdkFactory: (options: TracingBootstrapOptions) => SdkLike = buildNodeSdk,
|
|
81
|
+
): void {
|
|
82
|
+
if (started) return;
|
|
83
|
+
try {
|
|
84
|
+
const sdk: SdkLike = sdkFactory(opts);
|
|
85
|
+
sdk.start();
|
|
86
|
+
registerShutdown(() => sdk.shutdown());
|
|
87
|
+
started = true;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
90
|
+
process.stderr.write(`[nestjs-observability] WARN tracing init failed; continuing without tracing: ${message}\n`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Argument type for registerShutdown — async-safe best-effort shutdown hook. */
|
|
2
|
+
export type ShutdownHandler = () => Promise<void> | void;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Registers a process-level shutdown handler that runs once on SIGTERM, SIGINT, or
|
|
6
|
+
* `beforeExit`. Multiple handlers may be registered; all run, but each subscriber
|
|
7
|
+
* is invoked at most once per process (de-duplicated against prior SIGTERM/SIGINT).
|
|
8
|
+
*
|
|
9
|
+
* Best-effort by design — handler errors are swallowed at the call site; do not
|
|
10
|
+
* depend on successful flush from this entry point. Intended for OTel SDK flush
|
|
11
|
+
* and other best-effort cleanup work that must not crash a process on exit.
|
|
12
|
+
*/
|
|
13
|
+
export function registerShutdown(handler: ShutdownHandler): void {
|
|
14
|
+
let invoked = false;
|
|
15
|
+
const run = (): void => {
|
|
16
|
+
if (invoked) return;
|
|
17
|
+
invoked = true;
|
|
18
|
+
Promise.resolve()
|
|
19
|
+
.then(() => handler())
|
|
20
|
+
.catch(() => {
|
|
21
|
+
// intentional: best-effort shutdown, errors must not crash exit
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
process.once('SIGTERM', run);
|
|
26
|
+
process.once('SIGINT', run);
|
|
27
|
+
process.once('beforeExit', run);
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallHandler,
|
|
3
|
+
ExecutionContext,
|
|
4
|
+
Injectable,
|
|
5
|
+
NestInterceptor,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { trace } from '@opentelemetry/api';
|
|
8
|
+
import { RequestContextService } from '@nathapp/nestjs-logging';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
import { CORRELATION_ID_ATTRIBUTE } from '../constant/observability.constants';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Bidirectional bridge between the nestjs-logging correlation context and the active
|
|
14
|
+
* OTel span: sets the request correlation id as a span attribute, and writes the active
|
|
15
|
+
* trace_id/span_id back into the ALS store so downstream logs carry them. No-op when
|
|
16
|
+
* there is no active context, no active span, or nestjs-logging is not wired.
|
|
17
|
+
*
|
|
18
|
+
* Best-effort by design: a failure inside this interceptor must never break the
|
|
19
|
+
* request it observes.
|
|
20
|
+
*/
|
|
21
|
+
@Injectable()
|
|
22
|
+
export class TraceContextInterceptor implements NestInterceptor {
|
|
23
|
+
constructor(private readonly requestContext: RequestContextService) {}
|
|
24
|
+
|
|
25
|
+
intercept(_context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
|
26
|
+
try {
|
|
27
|
+
const span = trace.getActiveSpan();
|
|
28
|
+
if (span) {
|
|
29
|
+
const correlationId = this.requestContext.get('requestId');
|
|
30
|
+
if (correlationId) {
|
|
31
|
+
span.setAttribute(CORRELATION_ID_ATTRIBUTE, correlationId);
|
|
32
|
+
}
|
|
33
|
+
const { traceId, spanId } = span.spanContext();
|
|
34
|
+
this.requestContext.set('traceId', traceId);
|
|
35
|
+
this.requestContext.set('spanId', spanId);
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
/* swallow — correlation bridging is best-effort */
|
|
39
|
+
}
|
|
40
|
+
return next.handle();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SpanStatusCode } from '@opentelemetry/api';
|
|
2
|
+
import type { Span } from '@opentelemetry/api';
|
|
3
|
+
|
|
4
|
+
export function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
|
|
5
|
+
return (
|
|
6
|
+
typeof value === 'object' &&
|
|
7
|
+
value !== null &&
|
|
8
|
+
typeof (value as { then?: unknown }).then === 'function'
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function recordError(span: Span, err: unknown): void {
|
|
13
|
+
const exception: string | Error = err instanceof Error ? err : String(err);
|
|
14
|
+
span.recordException(exception);
|
|
15
|
+
span.setStatus({
|
|
16
|
+
code: SpanStatusCode.ERROR,
|
|
17
|
+
message: err instanceof Error ? err.message : String(err),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { trace } from '@opentelemetry/api';
|
|
2
|
+
import type { Span } from '@opentelemetry/api';
|
|
3
|
+
import { isPromiseLike, recordError } from './trace-internal';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Method decorator that wraps the decorated method in an active OTel span named after
|
|
7
|
+
* the class/method (or a supplied name).
|
|
8
|
+
*/
|
|
9
|
+
export function Trace(spanName?: string): MethodDecorator {
|
|
10
|
+
return (target, propertyKey, descriptor: PropertyDescriptor) => {
|
|
11
|
+
const original = descriptor.value as (...args: unknown[]) => unknown;
|
|
12
|
+
if (typeof original !== 'function') return descriptor;
|
|
13
|
+
|
|
14
|
+
const resolvedName =
|
|
15
|
+
spanName ??
|
|
16
|
+
`${(target as { constructor?: { name?: string } }).constructor?.name ?? 'Anonymous'}.${String(propertyKey)}`;
|
|
17
|
+
|
|
18
|
+
descriptor.value = function (this: unknown, ...args: unknown[]): unknown {
|
|
19
|
+
const tracer = trace.getTracer('@nathapp/nestjs-observability');
|
|
20
|
+
const ctx: { span: Span | null } = { span: null };
|
|
21
|
+
let result: unknown;
|
|
22
|
+
try {
|
|
23
|
+
result = tracer.startActiveSpan(resolvedName, (span) => {
|
|
24
|
+
ctx.span = span;
|
|
25
|
+
return original.apply(this, args);
|
|
26
|
+
});
|
|
27
|
+
} catch (err) {
|
|
28
|
+
if (ctx.span) {
|
|
29
|
+
recordError(ctx.span, err);
|
|
30
|
+
ctx.span.end();
|
|
31
|
+
ctx.span = null;
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (isPromiseLike(result)) {
|
|
37
|
+
return result.then(
|
|
38
|
+
(value) => {
|
|
39
|
+
if (ctx.span) {
|
|
40
|
+
ctx.span.end();
|
|
41
|
+
ctx.span = null;
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
},
|
|
45
|
+
(err: unknown) => {
|
|
46
|
+
if (ctx.span) {
|
|
47
|
+
recordError(ctx.span, err);
|
|
48
|
+
ctx.span.end();
|
|
49
|
+
ctx.span = null;
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ctx.span?.end();
|
|
57
|
+
ctx.span = null;
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return descriptor;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { trace } from '@opentelemetry/api';
|
|
3
|
+
import type { Tracer } from '@opentelemetry/api';
|
|
4
|
+
import { isPromiseLike, recordError } from './trace-internal';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Thin wrapper over the OTel tracer for manual spans. Wraps work in an active span,
|
|
8
|
+
* always ends the span in a finally, and records exceptions before rethrowing.
|
|
9
|
+
*/
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class TraceService {
|
|
12
|
+
private readonly tracer: Tracer;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.tracer = trace.getTracer('@nathapp/nestjs-observability');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
startActiveSpan<T>(name: string, fn: () => Promise<T> | T): Promise<T> {
|
|
19
|
+
return new Promise<T>((resolve, reject) => {
|
|
20
|
+
this.tracer.startActiveSpan(name, (span) => {
|
|
21
|
+
try {
|
|
22
|
+
const result = fn();
|
|
23
|
+
if (isPromiseLike(result)) {
|
|
24
|
+
result.then(
|
|
25
|
+
(value) => {
|
|
26
|
+
span.end();
|
|
27
|
+
resolve(value);
|
|
28
|
+
},
|
|
29
|
+
(err: unknown) => {
|
|
30
|
+
recordError(span, err);
|
|
31
|
+
span.end();
|
|
32
|
+
reject(err);
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
} else {
|
|
36
|
+
span.end();
|
|
37
|
+
resolve(result);
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
recordError(span, err);
|
|
41
|
+
span.end();
|
|
42
|
+
reject(err);
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nathapp/nestjs-observability",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "First-party metrics (Prometheus) and distributed tracing (OpenTelemetry) for NestJS, joined to the nathapp correlation-id context",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rimraf dist/ .turbo/",
|
|
9
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
10
|
+
"precommit": "lint-staged",
|
|
11
|
+
"test": "jest --config ./test/jest-test.json",
|
|
12
|
+
"test:cov": "jest --config ./test/jest-test.json --coverage",
|
|
13
|
+
"test:watch": "jest --config ./test/jest-test.json --watch",
|
|
14
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
15
|
+
"lint": "eslint -c .eslintrc.js",
|
|
16
|
+
"lint:fix": "eslint -c .eslintrc.js --fix"
|
|
17
|
+
},
|
|
18
|
+
"author": "William Khoo",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=16"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@opentelemetry/api": "^1.9.1",
|
|
25
|
+
"@opentelemetry/auto-instrumentations-node": "^0.78.0",
|
|
26
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
|
|
27
|
+
"@opentelemetry/resources": "^2.9.0",
|
|
28
|
+
"@opentelemetry/sdk-node": "^0.220.0",
|
|
29
|
+
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
30
|
+
"@opentelemetry/semantic-conventions": "^1.42.0",
|
|
31
|
+
"@willsoto/nestjs-prometheus": "^6.0.0",
|
|
32
|
+
"prom-client": "^15.1.3"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@nathapp/nestjs-common": "^3.0.0",
|
|
36
|
+
"@nathapp/nestjs-logging": "^3.0.0",
|
|
37
|
+
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
38
|
+
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
39
|
+
"rxjs": "^7.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@nathapp/eslint-config": "1.0.1",
|
|
43
|
+
"@nathapp/nestjs-common": "^3.3.0",
|
|
44
|
+
"@nathapp/nestjs-logging": "^3.3.0",
|
|
45
|
+
"@nathapp/typescript-config": "1.0.1",
|
|
46
|
+
"@nestjs/common": "^11.0.0",
|
|
47
|
+
"@nestjs/core": "^11.0.0",
|
|
48
|
+
"@nestjs/testing": "^11.0.0",
|
|
49
|
+
"@types/jest": "^29.5.2",
|
|
50
|
+
"eslint": "^8.57.0",
|
|
51
|
+
"jest": "^29.5.0",
|
|
52
|
+
"reflect-metadata": "^0.1.13",
|
|
53
|
+
"rxjs": "^7.8.0",
|
|
54
|
+
"ts-jest": "^29.1.0",
|
|
55
|
+
"typescript": "^5"
|
|
56
|
+
},
|
|
57
|
+
"directories": {
|
|
58
|
+
"lib": "lib"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": ["js", "json", "ts", "d.ts"],
|
|
3
|
+
"rootDir": "../",
|
|
4
|
+
"testEnvironment": "node",
|
|
5
|
+
"testMatch": ["**/.nax/**/*.test.ts"],
|
|
6
|
+
"transform": {
|
|
7
|
+
"^.+\\.(t)s$": [
|
|
8
|
+
"ts-jest",
|
|
9
|
+
{
|
|
10
|
+
"diagnostics": true,
|
|
11
|
+
"tsconfig": {
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"experimentalDecorators": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"collectCoverageFrom": [
|
|
20
|
+
"lib/**/*.ts",
|
|
21
|
+
"!lib/**/*.spec.ts",
|
|
22
|
+
"!lib/**/*.d.ts",
|
|
23
|
+
"!**/node_modules/**"
|
|
24
|
+
],
|
|
25
|
+
"forceExit": true,
|
|
26
|
+
"maxWorkers": 1
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": [
|
|
3
|
+
"js",
|
|
4
|
+
"json",
|
|
5
|
+
"ts",
|
|
6
|
+
"d.ts"
|
|
7
|
+
],
|
|
8
|
+
"rootDir": "../",
|
|
9
|
+
"testEnvironment": "node",
|
|
10
|
+
"testRegex": ".spec.ts$",
|
|
11
|
+
"transform": {
|
|
12
|
+
"^.+\\.(t)s$": [
|
|
13
|
+
"ts-jest",
|
|
14
|
+
{
|
|
15
|
+
"diagnostics": true
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"collectCoverageFrom": [
|
|
20
|
+
"lib/**/*.ts",
|
|
21
|
+
"!lib/**/*.spec.ts",
|
|
22
|
+
"!lib/**/*.d.ts",
|
|
23
|
+
"!lib/**/index.ts",
|
|
24
|
+
"!lib/**/*.interface.ts",
|
|
25
|
+
"!**/node_modules/**"
|
|
26
|
+
],
|
|
27
|
+
"coverageProvider": "v8"
|
|
28
|
+
}
|