@lokalise/fastify-extras 16.2.0 → 16.2.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ErrorReporter } from '@lokalise/node-core';
|
|
2
2
|
import type { FastifyRequest, FastifyReply, FastifyInstance } from 'fastify';
|
|
3
3
|
export type FreeformRecord = Record<string, any>;
|
|
4
|
-
type
|
|
4
|
+
type ErrorResponseObject = {
|
|
5
5
|
statusCode: number;
|
|
6
6
|
payload: {
|
|
7
7
|
message: string;
|
|
@@ -11,7 +11,7 @@ type ResponseObject = {
|
|
|
11
11
|
};
|
|
12
12
|
export type ErrorHandlerParams = {
|
|
13
13
|
errorReporter: ErrorReporter;
|
|
14
|
-
resolveResponseObject?: (error: FreeformRecord) =>
|
|
14
|
+
resolveResponseObject?: (error: FreeformRecord) => ErrorResponseObject | undefined;
|
|
15
15
|
resolveLogObject?: (error: unknown) => FreeformRecord | undefined;
|
|
16
16
|
};
|
|
17
17
|
export declare function createErrorHandler(params: ErrorHandlerParams): (this: FastifyInstance, error: FreeformRecord, request: FastifyRequest, reply: FastifyReply) => void;
|
|
@@ -4,12 +4,14 @@ exports.createErrorHandler = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_core_1 = require("@lokalise/node-core");
|
|
6
6
|
const pino_1 = tslib_1.__importDefault(require("pino"));
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
7
|
const knownAuthErrors = new Set([
|
|
9
8
|
'FST_JWT_NO_AUTHORIZATION_IN_HEADER',
|
|
10
9
|
'FST_JWT_AUTHORIZATION_TOKEN_EXPIRED',
|
|
11
10
|
'FST_JWT_AUTHORIZATION_TOKEN_INVALID',
|
|
12
11
|
]);
|
|
12
|
+
function isZodError(value) {
|
|
13
|
+
return value.name === 'ZodError';
|
|
14
|
+
}
|
|
13
15
|
function resolveLogObject(error) {
|
|
14
16
|
if ((0, node_core_1.isInternalError)(error)) {
|
|
15
17
|
return {
|
|
@@ -40,7 +42,7 @@ function resolveResponseObject(error) {
|
|
|
40
42
|
},
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
|
-
if (error
|
|
45
|
+
if (isZodError(error)) {
|
|
44
46
|
return {
|
|
45
47
|
statusCode: 400,
|
|
46
48
|
payload: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../lib/errors/errorHandler.ts"],"names":[],"mappings":";;;;AACA,mDAK4B;AAE5B,wDAAuB;
|
|
1
|
+
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../lib/errors/errorHandler.ts"],"names":[],"mappings":";;;;AACA,mDAK4B;AAE5B,wDAAuB;AAMvB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,oCAAoC;IACpC,qCAAqC;IACrC,qCAAqC;CACtC,CAAC,CAAA;AAWF,SAAS,UAAU,CAAC,KAAc;IAChC,OAAQ,KAAkB,CAAC,IAAI,KAAK,UAAU,CAAA;AAChD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,IAAA,2BAAe,EAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,SAAS;YACrB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;YAClE,KAAK,EAAE,cAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC;SACH,CAAA;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAA,oBAAQ,EAAC,KAAK,CAAC,C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EAAE;YACP,OAAO,EAAE,uBAAuB;YAChC,SAAS,EAAE,uBAAuB;SACnC;KACF,CAAA;AACH,CAAC;AAQD,SAAgB,kBAAkB,CAAC,MAA0B;IAC3D,OAAO,SAAS,YAAY,CAE1B,KAAqB,EACrB,OAAuB,EACvB,KAAmB;QAEnB,MAAM,SAAS,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAE7E,IAAI,IAAA,2BAAe,EAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACxC,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAA;QAC5F,IAAI,cAAc,CAAC,UAAU,IAAI,GAAG,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,KAAK,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC3E,CAAC,CAAA;AACH,CAAC;AApBD,gDAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/fastify-extras",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.2",
|
|
4
4
|
"description": "Opinionated set of fastify plugins, commonly used in Lokalise",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Lokalise",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@bugsnag/js": "^7.22.2",
|
|
47
47
|
"@opentelemetry/api": "1.7.0",
|
|
48
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "0.45.0",
|
|
49
|
-
"@opentelemetry/instrumentation": "0.45.0",
|
|
50
|
-
"@opentelemetry/resources": "1.18.0",
|
|
51
|
-
"@opentelemetry/sdk-trace-base": "1.18.0",
|
|
52
|
-
"@opentelemetry/sdk-trace-node": "1.18.0",
|
|
53
|
-
"@opentelemetry/semantic-conventions": "1.18.0",
|
|
48
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "~0.45.0",
|
|
49
|
+
"@opentelemetry/instrumentation": "~0.45.0",
|
|
50
|
+
"@opentelemetry/resources": "~1.18.0",
|
|
51
|
+
"@opentelemetry/sdk-trace-base": "~1.18.0",
|
|
52
|
+
"@opentelemetry/sdk-trace-node": "~1.18.0",
|
|
53
|
+
"@opentelemetry/semantic-conventions": "~1.18.0",
|
|
54
54
|
"@prisma/instrumentation": "^5.6.0",
|
|
55
55
|
"@splitsoftware/splitio": "^10.23.1",
|
|
56
56
|
"@amplitude/analytics-node": "^1.3.4",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@fastify/request-context": "^5.0.0",
|
|
70
|
-
"@lokalise/node-core": "^8.
|
|
70
|
+
"@lokalise/node-core": "^8.4.0",
|
|
71
71
|
"@types/newrelic": "^9.14.3",
|
|
72
72
|
"@types/node": "^20.10.1",
|
|
73
73
|
"@amplitude/analytics-types": "^2.3.1",
|
|
@@ -81,12 +81,13 @@
|
|
|
81
81
|
"eslint-plugin-vitest": "^0.3.10",
|
|
82
82
|
"eslint-plugin-prettier": "^5.0.0",
|
|
83
83
|
"fastify": "^4.24.3",
|
|
84
|
-
"newrelic": "11.6.
|
|
84
|
+
"newrelic": "11.6.1",
|
|
85
85
|
"pino": "^8.16.2",
|
|
86
|
+
"pino-pretty": "^10.2.3",
|
|
86
87
|
"prettier": "^3.1.0",
|
|
87
88
|
"shx": "^0.3.4",
|
|
88
89
|
"ts-node": "^10.9.1",
|
|
89
|
-
"typescript": "^5.3.
|
|
90
|
+
"typescript": "^5.3.3",
|
|
90
91
|
"vitest": "^0.34.6",
|
|
91
92
|
"vite": "4.5.0",
|
|
92
93
|
"zod": "^3.22.4"
|