@kuckit/api 2.0.3 → 2.0.6
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/error-handler.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ORPCError } from "@orpc/server";
|
|
2
|
+
import { ORPCErrorCode } from "@orpc/client";
|
|
2
3
|
|
|
3
4
|
//#region src/error-handler.d.ts
|
|
4
|
-
|
|
5
|
+
interface ErrorData {
|
|
6
|
+
code: string;
|
|
7
|
+
meta?: Record<string, unknown>;
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
10
|
* Map AppError to oRPC errors
|
|
7
11
|
* Preserves error details for logging while providing proper HTTP status codes
|
|
8
12
|
*/
|
|
9
|
-
declare const mapAppErrorToORPC: (error: unknown) => ORPCError
|
|
13
|
+
declare const mapAppErrorToORPC: (error: unknown) => ORPCError<ORPCErrorCode, ErrorData | undefined>;
|
|
10
14
|
//#endregion
|
|
11
15
|
export { mapAppErrorToORPC };
|
|
12
16
|
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","names":[],"sources":["../src/error-handler.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","names":[],"sources":["../src/error-handler.ts"],"sourcesContent":[],"mappings":";;;;UAIU,SAAA;;EAAA,IAAA,CAAA,EAEF,MAFW,CAAA,MAAA,EAAA,OAEX,CAAM;AAOd;;;;;cAAa,uCAEV,UAAU,eAAe"}
|
package/dist/error-handler.js
CHANGED
|
@@ -9,7 +9,7 @@ const mapAppErrorToORPC = (error) => {
|
|
|
9
9
|
const appError = error;
|
|
10
10
|
if (!appError?.code) return new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
11
11
|
message: error instanceof Error ? error.message : "Unknown error",
|
|
12
|
-
code: "INTERNAL_SERVER_ERROR"
|
|
12
|
+
data: { code: "INTERNAL_SERVER_ERROR" }
|
|
13
13
|
});
|
|
14
14
|
return new ORPCError({
|
|
15
15
|
400: "BAD_REQUEST",
|
|
@@ -20,8 +20,10 @@ const mapAppErrorToORPC = (error) => {
|
|
|
20
20
|
500: "INTERNAL_SERVER_ERROR"
|
|
21
21
|
}[appError.statusCode] || "INTERNAL_SERVER_ERROR", {
|
|
22
22
|
message: appError.message,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
data: {
|
|
24
|
+
code: appError.code,
|
|
25
|
+
meta: appError.meta
|
|
26
|
+
}
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","names":[],"sources":["../src/error-handler.ts"],"sourcesContent":["import { ORPCError } from '@orpc/server'\nimport type { AppError } from '@kuckit/domain'\n\n/**\n * Map AppError to oRPC errors\n * Preserves error details for logging while providing proper HTTP status codes\n */\nexport const mapAppErrorToORPC = (
|
|
1
|
+
{"version":3,"file":"error-handler.js","names":[],"sources":["../src/error-handler.ts"],"sourcesContent":["import { ORPCError } from '@orpc/server'\nimport type { ORPCErrorCode } from '@orpc/client'\nimport type { AppError } from '@kuckit/domain'\n\ninterface ErrorData {\n\tcode: string\n\tmeta?: Record<string, unknown>\n}\n\n/**\n * Map AppError to oRPC errors\n * Preserves error details for logging while providing proper HTTP status codes\n */\nexport const mapAppErrorToORPC = (\n\terror: unknown\n): ORPCError<ORPCErrorCode, ErrorData | undefined> => {\n\tconst appError = error as AppError\n\n\tif (!appError?.code) {\n\t\t// Not an AppError, wrap as internal server error\n\t\treturn new ORPCError('INTERNAL_SERVER_ERROR', {\n\t\t\tmessage: error instanceof Error ? error.message : 'Unknown error',\n\t\t\tdata: { code: 'INTERNAL_SERVER_ERROR' },\n\t\t})\n\t}\n\n\t// Map status codes to oRPC error codes\n\tconst statusCodeMap: Record<number, ORPCErrorCode> = {\n\t\t400: 'BAD_REQUEST',\n\t\t401: 'UNAUTHORIZED',\n\t\t403: 'FORBIDDEN',\n\t\t404: 'NOT_FOUND',\n\t\t409: 'CONFLICT',\n\t\t500: 'INTERNAL_SERVER_ERROR',\n\t}\n\n\tconst orpcCode = statusCodeMap[appError.statusCode] || 'INTERNAL_SERVER_ERROR'\n\n\treturn new ORPCError(orpcCode, {\n\t\tmessage: appError.message,\n\t\tdata: { code: appError.code, meta: appError.meta },\n\t})\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBACZ,UACqD;CACrD,MAAM,WAAW;AAEjB,KAAI,CAAC,UAAU,KAEd,QAAO,IAAI,UAAU,yBAAyB;EAC7C,SAAS,iBAAiB,QAAQ,MAAM,UAAU;EAClD,MAAM,EAAE,MAAM,yBAAyB;EACvC,CAAC;AAeH,QAAO,IAAI,UAX0C;EACpD,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,CAE8B,SAAS,eAAe,yBAExB;EAC9B,SAAS,SAAS;EAClB,MAAM;GAAE,MAAM,SAAS;GAAM,MAAM,SAAS;GAAM;EAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuckit/api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dotenv": "^17.2.2",
|
|
41
41
|
"zod": "^4.1.11",
|
|
42
42
|
"awilix": "^12.0.5",
|
|
43
|
-
"@kuckit/auth": "^2.0.
|
|
44
|
-
"@kuckit/db": "^2.0.
|
|
45
|
-
"@kuckit/contracts": "^2.0.
|
|
43
|
+
"@kuckit/auth": "^2.0.6",
|
|
44
|
+
"@kuckit/db": "^2.0.6",
|
|
45
|
+
"@kuckit/contracts": "^2.0.6"
|
|
46
46
|
}
|
|
47
47
|
}
|