@volontariapp/errors-nest 0.1.0-next.20260403085938
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/filters/global-exception.filter.d.ts +6 -0
- package/dist/filters/global-exception.filter.d.ts.map +1 -0
- package/dist/filters/global-exception.filter.js +86 -0
- package/dist/filters/global-exception.filter.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/swagger/api-error.decorator.d.ts +15 -0
- package/dist/swagger/api-error.decorator.d.ts.map +1 -0
- package/dist/swagger/api-error.decorator.js +37 -0
- package/dist/swagger/api-error.decorator.js.map +1 -0
- package/dist/swagger/error-response.dto.d.ts +9 -0
- package/dist/swagger/error-response.dto.d.ts.map +1 -0
- package/dist/swagger/error-response.dto.js +63 -0
- package/dist/swagger/error-response.dto.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
+
export declare class GlobalExceptionFilter implements ExceptionFilter {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
catch(exception: unknown, host: ArgumentsHost): unknown;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=global-exception.filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-exception.filter.d.ts","sourceRoot":"","sources":["../../src/filters/global-exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMrE,qBACa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IAEjE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa;CAyE9C"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var GlobalExceptionFilter_1;
|
|
8
|
+
import { Catch, HttpException, HttpStatus, Logger } from '@nestjs/common';
|
|
9
|
+
import { RpcException } from '@nestjs/microservices';
|
|
10
|
+
import { BaseError, GrpcStatus } from '@volontariapp/errors';
|
|
11
|
+
let GlobalExceptionFilter = GlobalExceptionFilter_1 = class GlobalExceptionFilter {
|
|
12
|
+
logger = new Logger(GlobalExceptionFilter_1.name);
|
|
13
|
+
catch(exception, host) {
|
|
14
|
+
const isBaseError = exception instanceof BaseError;
|
|
15
|
+
const isHttpException = exception instanceof HttpException;
|
|
16
|
+
let status = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
17
|
+
let message = 'Internal Server Error';
|
|
18
|
+
let code = 'INTERNAL_ERROR';
|
|
19
|
+
let details = undefined;
|
|
20
|
+
let grpcCode = GrpcStatus.INTERNAL;
|
|
21
|
+
if (isBaseError) {
|
|
22
|
+
status = exception.statusCode;
|
|
23
|
+
message = exception.message;
|
|
24
|
+
code = exception.code;
|
|
25
|
+
details = exception.details;
|
|
26
|
+
grpcCode = exception.grpcCode;
|
|
27
|
+
}
|
|
28
|
+
else if (isHttpException) {
|
|
29
|
+
status = exception.getStatus();
|
|
30
|
+
const response = exception.getResponse();
|
|
31
|
+
if (typeof response === 'string') {
|
|
32
|
+
message = response;
|
|
33
|
+
}
|
|
34
|
+
else if (typeof response === 'object' && response !== null && 'message' in response) {
|
|
35
|
+
message = String(response.message);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
message = exception.message;
|
|
39
|
+
}
|
|
40
|
+
code = exception.name;
|
|
41
|
+
}
|
|
42
|
+
else if (exception instanceof Error) {
|
|
43
|
+
message = exception.message;
|
|
44
|
+
this.logger.error(`Unhandled Exception: ${exception.message}`, exception.stack);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.logger.error(`Unknown Exception: ${JSON.stringify(exception)}`);
|
|
48
|
+
}
|
|
49
|
+
const type = host.getType();
|
|
50
|
+
if (type === 'http') {
|
|
51
|
+
const ctx = host.switchToHttp();
|
|
52
|
+
const response = ctx.getResponse();
|
|
53
|
+
const request = ctx.getRequest();
|
|
54
|
+
const errorResponse = {
|
|
55
|
+
statusCode: status,
|
|
56
|
+
code,
|
|
57
|
+
message,
|
|
58
|
+
details,
|
|
59
|
+
timestamp: new Date().toISOString(),
|
|
60
|
+
path: request.url,
|
|
61
|
+
};
|
|
62
|
+
response.status(status).json(errorResponse);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (type === 'rpc') {
|
|
66
|
+
const rpcException = new RpcException({
|
|
67
|
+
code: isBaseError ? grpcCode : GrpcStatus.INTERNAL,
|
|
68
|
+
message: JSON.stringify({
|
|
69
|
+
statusCode: status,
|
|
70
|
+
code,
|
|
71
|
+
message,
|
|
72
|
+
details,
|
|
73
|
+
timestamp: new Date().toISOString(),
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
return rpcException;
|
|
77
|
+
}
|
|
78
|
+
this.logger.warn(`Unknown context type: ${type}`);
|
|
79
|
+
return exception;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
GlobalExceptionFilter = GlobalExceptionFilter_1 = __decorate([
|
|
83
|
+
Catch()
|
|
84
|
+
], GlobalExceptionFilter);
|
|
85
|
+
export { GlobalExceptionFilter };
|
|
86
|
+
//# sourceMappingURL=global-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
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AK,KAAK,EAAE,CAAC;YACnB,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;gBACpC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ;gBAClD,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACtB,UAAU,EAAE,MAAM;oBAClB,IAAI;oBACJ,OAAO;oBACP,OAAO;oBACP,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACpC,CAAC;aACH,CAAC,CAAC;YACH,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AA5EY,qBAAqB;IADjC,KAAK,EAAE;GACK,qBAAqB,CA4EjC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Type } from '@nestjs/common';
|
|
2
|
+
export declare function ApiErrorResponse(options: {
|
|
3
|
+
status: number;
|
|
4
|
+
description?: string;
|
|
5
|
+
type?: Type<unknown> | [Type<unknown>] | string;
|
|
6
|
+
}): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
+
export declare function ApiNotFoundResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
8
|
+
export declare function ApiBadRequestResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
9
|
+
export declare function ApiUnauthorizedResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
10
|
+
export declare function ApiForbiddenResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
11
|
+
export declare function ApiInternalServerErrorResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
12
|
+
export declare function ApiConflictResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
13
|
+
export declare function ApiUnprocessableEntityResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
14
|
+
export declare function ApiTooManyRequestsResponse(description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
15
|
+
//# sourceMappingURL=api-error.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-error.decorator.d.ts","sourceRoot":"","sources":["../../src/swagger/api-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAgB3C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC;CACjD,+IASA;AAED,wBAAgB,mBAAmB,CAAC,WAAW,SAA8B,+IAE5E;AAED,wBAAgB,qBAAqB,CAAC,WAAW,SAAgC,+IAEhF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,SAAkC,+IAEpF;AAED,wBAAgB,oBAAoB,CAAC,WAAW,SAA+B,+IAE9E;AAED,wBAAgB,8BAA8B,CAAC,WAAW,SAAoC,+IAE7F;AAED,wBAAgB,mBAAmB,CAAC,WAAW,SAA8B,+IAE5E;AAED,wBAAgB,8BAA8B,CAC5C,WAAW,SAAyC,+IAGrD;AAED,wBAAgB,0BAA0B,CAAC,WAAW,SAAqC,+IAE1F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiResponse } from '@nestjs/swagger';
|
|
3
|
+
import { BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError, TooManyRequestsError, UnauthorizedError, UnprocessableEntityError, } from '@volontariapp/errors';
|
|
4
|
+
import { ErrorResponseDto } from './error-response.dto.js';
|
|
5
|
+
export function ApiErrorResponse(options) {
|
|
6
|
+
const { status, description, type = ErrorResponseDto } = options;
|
|
7
|
+
return applyDecorators(ApiResponse({
|
|
8
|
+
status,
|
|
9
|
+
description: description ?? `Error ${status.toString()}`,
|
|
10
|
+
type,
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
export function ApiNotFoundResponse(description = new NotFoundError().message) {
|
|
14
|
+
return ApiErrorResponse({ status: new NotFoundError().statusCode, description });
|
|
15
|
+
}
|
|
16
|
+
export function ApiBadRequestResponse(description = new BadRequestError().message) {
|
|
17
|
+
return ApiErrorResponse({ status: new BadRequestError().statusCode, description });
|
|
18
|
+
}
|
|
19
|
+
export function ApiUnauthorizedResponse(description = new UnauthorizedError().message) {
|
|
20
|
+
return ApiErrorResponse({ status: new UnauthorizedError().statusCode, description });
|
|
21
|
+
}
|
|
22
|
+
export function ApiForbiddenResponse(description = new ForbiddenError().message) {
|
|
23
|
+
return ApiErrorResponse({ status: new ForbiddenError().statusCode, description });
|
|
24
|
+
}
|
|
25
|
+
export function ApiInternalServerErrorResponse(description = new InternalServerError().message) {
|
|
26
|
+
return ApiErrorResponse({ status: new InternalServerError().statusCode, description });
|
|
27
|
+
}
|
|
28
|
+
export function ApiConflictResponse(description = new ConflictError().message) {
|
|
29
|
+
return ApiErrorResponse({ status: new ConflictError().statusCode, description });
|
|
30
|
+
}
|
|
31
|
+
export function ApiUnprocessableEntityResponse(description = new UnprocessableEntityError().message) {
|
|
32
|
+
return ApiErrorResponse({ status: new UnprocessableEntityError().statusCode, description });
|
|
33
|
+
}
|
|
34
|
+
export function ApiTooManyRequestsResponse(description = new TooManyRequestsError().message) {
|
|
35
|
+
return ApiErrorResponse({ status: new TooManyRequestsError().statusCode, description });
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=api-error.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-error.decorator.js","sourceRoot":"","sources":["../../src/swagger/api-error.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,gBAAgB,CAAC,OAIhC;IACC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;IACjE,OAAO,eAAe,CACpB,WAAW,CAAC;Q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UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,WAAW,GAAG,IAAI,wBAAwB,EAAE,CAAC,OAAO;IAEpD,OAAO,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,wBAAwB,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,WAAW,GAAG,IAAI,oBAAoB,EAAE,CAAC,OAAO;IACzF,OAAO,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-response.dto.d.ts","sourceRoot":"","sources":["../../src/swagger/error-response.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IAKpB,UAAU,EAAG,MAAM,CAAC;IAMpB,IAAI,EAAG,MAAM,CAAC;IAMd,OAAO,EAAG,MAAM,CAAC;IAOjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAMlC,SAAS,EAAG,MAAM,CAAC;IAOnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
11
|
+
export class ErrorResponseDto {
|
|
12
|
+
statusCode;
|
|
13
|
+
code;
|
|
14
|
+
message;
|
|
15
|
+
details;
|
|
16
|
+
timestamp;
|
|
17
|
+
path;
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
ApiProperty({
|
|
21
|
+
description: 'The HTTP status code',
|
|
22
|
+
example: 400,
|
|
23
|
+
}),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], ErrorResponseDto.prototype, "statusCode", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
ApiProperty({
|
|
28
|
+
description: 'The internal error code',
|
|
29
|
+
example: 'BAD_REQUEST',
|
|
30
|
+
}),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], ErrorResponseDto.prototype, "code", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
ApiProperty({
|
|
35
|
+
description: 'The error message',
|
|
36
|
+
example: 'Invalid input parameters',
|
|
37
|
+
}),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], ErrorResponseDto.prototype, "message", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
ApiProperty({
|
|
42
|
+
description: 'Additional error details',
|
|
43
|
+
required: false,
|
|
44
|
+
example: { field: 'email', issue: 'invalid format' },
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], ErrorResponseDto.prototype, "details", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
ApiProperty({
|
|
50
|
+
description: 'Timestamp when the error occurred',
|
|
51
|
+
example: '2023-10-01T10:00:00.000Z',
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], ErrorResponseDto.prototype, "timestamp", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
ApiProperty({
|
|
57
|
+
description: 'The path where the error occurred',
|
|
58
|
+
required: false,
|
|
59
|
+
example: '/api/v1/users',
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], ErrorResponseDto.prototype, "path", void 0);
|
|
63
|
+
//# sourceMappingURL=error-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-response.dto.js","sourceRoot":"","sources":["../../src/swagger/error-response.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,gBAAgB;IAKpB,UAAU,CAAU;IAMpB,IAAI,CAAU;IAMd,OAAO,CAAU;IAOjB,OAAO,CAA2B;IAMlC,SAAS,CAAU;IAOnB,IAAI,CAAU;CACtB;AAjCQ;IAJN,WAAW,CAAC;QACX,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,GAAG;KACb,CAAC;;oDACyB;AAMpB;IAJN,WAAW,CAAC;QACX,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,aAAa;KACvB,CAAC;;8CACmB;AAMd;IAJN,WAAW,CAAC;QACX,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE,0BAA0B;KACpC,CAAC;;iDACsB;AAOjB;IALN,WAAW,CAAC;QACX,WAAW,EAAE,0BAA0B;QACvC,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE;KACrD,CAAC;;iDACuC;AAMlC;IAJN,WAAW,CAAC;QACX,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,0BAA0B;KACpC,CAAC;;mDACwB;AAOnB;IALN,WAAW,CAAC;QACX,WAAW,EAAE,mCAAmC;QAChD,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,eAAe;KACzB,CAAC;;8CACmB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volontariapp/errors-nest",
|
|
3
|
+
"version": "0.1.0-next.20260403085938",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Volontariapp/npm-packages.git"
|
|
11
|
+
},
|
|
12
|
+
"description": "",
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24.14.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepublishOnly": "yarn build",
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"lint": "eslint src/",
|
|
33
|
+
"test": "echo \"No tests yet\""
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@nestjs/common": "^11.0.0",
|
|
37
|
+
"@nestjs/core": "^11.0.0",
|
|
38
|
+
"@nestjs/microservices": "^11.0.0",
|
|
39
|
+
"@nestjs/swagger": "^11.0.0",
|
|
40
|
+
"typescript": "5.7.3"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@volontariapp/errors": "workspace:*"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
47
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
48
|
+
"@nestjs/microservices": "^10.0.0 || ^11.0.0",
|
|
49
|
+
"@nestjs/swagger": "^8.0.0 || ^11.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|