@arkyn/server 1.4.36 → 1.4.38

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.
@@ -46,7 +46,7 @@ const globalErrorHandler = (error) => {
46
46
  return serverError({
47
47
  message: error?.message || "Server error | Message not found",
48
48
  name: "Server Error",
49
- cause: error,
49
+ cause: error.cause || "Unknown",
50
50
  });
51
51
  }
52
52
  };
@@ -1,8 +1,9 @@
1
- declare function serverError(error: Error): import("undici-types").Response;
1
+ declare function serverError(error: ServerError): import("undici-types").Response;
2
2
  declare class ServerError {
3
3
  name: string;
4
4
  message: string;
5
- constructor(message: string);
5
+ cause: any;
6
+ constructor(message: string, cause?: any);
6
7
  }
7
8
  export { serverError, ServerError };
8
9
  //# sourceMappingURL=serverError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/serverError.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,mCAchC;AAED,cAAM,WAAW;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/serverError.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,KAAK,EAAE,WAAW,mCActC;AAED,cAAM,WAAW;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;gBAEC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;CAKzC;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC"}
@@ -13,9 +13,11 @@ function serverError(error) {
13
13
  class ServerError {
14
14
  name;
15
15
  message;
16
- constructor(message) {
16
+ cause;
17
+ constructor(message, cause) {
17
18
  this.name = "ServerError";
18
19
  this.message = message;
20
+ this.cause = cause;
19
21
  }
20
22
  }
21
23
  export { serverError, ServerError };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "1.4.36",
3
+ "version": "1.4.38",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "scripts": {
9
- "build": "rm -rf ./dist && bunx tsc --project tsconfig.json",
9
+ "clean": "rm -rf dist",
10
+ "build": "bun run clean && bunx tsc --project tsconfig.json",
10
11
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
11
12
  },
12
13
  "dependencies": {
@@ -56,7 +56,7 @@ const globalErrorHandler = (error: any) => {
56
56
  return serverError({
57
57
  message: error?.message || "Server error | Message not found",
58
58
  name: "Server Error",
59
- cause: error,
59
+ cause: error.cause || "Unknown",
60
60
  });
61
61
  }
62
62
  };
@@ -1,4 +1,4 @@
1
- function serverError(error: Error) {
1
+ function serverError(error: ServerError) {
2
2
  return new Response(
3
3
  JSON.stringify({
4
4
  status: 500,
@@ -17,10 +17,12 @@ function serverError(error: Error) {
17
17
  class ServerError {
18
18
  name: string;
19
19
  message: string;
20
+ cause: any;
20
21
 
21
- constructor(message: string) {
22
+ constructor(message: string, cause?: any) {
22
23
  this.name = "ServerError";
23
24
  this.message = message;
25
+ this.cause = cause;
24
26
  }
25
27
  }
26
28