@arkyn/server 1.4.30 → 1.4.32

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.
Files changed (43) hide show
  1. package/dist/helpers/globalErrorHandler.d.ts +1 -1
  2. package/dist/helpers/globalErrorHandler.d.ts.map +1 -1
  3. package/dist/httpBadResponses/badRequest.d.ts +4 -3
  4. package/dist/httpBadResponses/badRequest.d.ts.map +1 -1
  5. package/dist/httpBadResponses/badRequest.js +5 -4
  6. package/dist/httpBadResponses/conflict.d.ts +4 -3
  7. package/dist/httpBadResponses/conflict.d.ts.map +1 -1
  8. package/dist/httpBadResponses/conflict.js +5 -4
  9. package/dist/httpBadResponses/forbidden.d.ts +4 -3
  10. package/dist/httpBadResponses/forbidden.d.ts.map +1 -1
  11. package/dist/httpBadResponses/forbidden.js +5 -4
  12. package/dist/httpBadResponses/notFound.d.ts +4 -3
  13. package/dist/httpBadResponses/notFound.d.ts.map +1 -1
  14. package/dist/httpBadResponses/notFound.js +5 -4
  15. package/dist/httpBadResponses/serverError.d.ts +4 -3
  16. package/dist/httpBadResponses/serverError.d.ts.map +1 -1
  17. package/dist/httpBadResponses/serverError.js +5 -4
  18. package/dist/httpBadResponses/unauthorized.d.ts +4 -3
  19. package/dist/httpBadResponses/unauthorized.d.ts.map +1 -1
  20. package/dist/httpBadResponses/unauthorized.js +5 -4
  21. package/dist/httpBadResponses/unprocessableEntity.d.ts +4 -3
  22. package/dist/httpBadResponses/unprocessableEntity.d.ts.map +1 -1
  23. package/dist/httpBadResponses/unprocessableEntity.js +6 -4
  24. package/dist/httpResponses/created.d.ts +1 -1
  25. package/dist/httpResponses/created.d.ts.map +1 -1
  26. package/dist/httpResponses/created.js +1 -1
  27. package/dist/httpResponses/success.d.ts +1 -1
  28. package/dist/httpResponses/success.d.ts.map +1 -1
  29. package/dist/httpResponses/success.js +1 -1
  30. package/dist/httpResponses/updated.d.ts +1 -1
  31. package/dist/httpResponses/updated.d.ts.map +1 -1
  32. package/dist/httpResponses/updated.js +1 -1
  33. package/package.json +1 -1
  34. package/src/httpBadResponses/badRequest.ts +15 -12
  35. package/src/httpBadResponses/conflict.ts +15 -12
  36. package/src/httpBadResponses/forbidden.ts +15 -12
  37. package/src/httpBadResponses/notFound.ts +15 -12
  38. package/src/httpBadResponses/serverError.ts +15 -12
  39. package/src/httpBadResponses/unauthorized.ts +15 -12
  40. package/src/httpBadResponses/unprocessableEntity.ts +17 -16
  41. package/src/httpResponses/created.ts +2 -2
  42. package/src/httpResponses/success.ts +2 -2
  43. package/src/httpResponses/updated.ts +2 -2
@@ -1,3 +1,3 @@
1
- declare const globalErrorHandler: (error: any) => import("@arkyn/types").HttpResponse | import("@arkyn/types").HttpDataResponse;
1
+ declare const globalErrorHandler: (error: any) => import("undici-types").Response;
2
2
  export { globalErrorHandler };
3
3
  //# sourceMappingURL=globalErrorHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"globalErrorHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/globalErrorHandler.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,kBAAkB,UAAW,GAAG,kFAuBrC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"globalErrorHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/globalErrorHandler.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,kBAAkB,UAAW,GAAG,oCAuBrC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function badRequest(error: Error): HttpResponse;
3
- declare class BadRequestError extends Error {
1
+ declare function badRequest(error: Error): import("undici-types").Response;
2
+ declare class BadRequestError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { badRequest, BadRequestError };
@@ -1 +1 @@
1
- {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/badRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQ9C;AAED,cAAM,eAAgB,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAK5B;AAED,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/badRequest.ts"],"names":[],"mappings":"AAAA,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,mCAW/B;AAED,cAAM,eAAe;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  function badRequest(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 400,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 400 });
9
9
  }
10
- class BadRequestError extends Error {
10
+ class BadRequestError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "BadRequestError";
14
15
  this.message = message;
15
16
  }
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function conflict(error: Error): HttpResponse;
3
- declare class ConflictError extends Error {
1
+ declare function conflict(error: Error): import("undici-types").Response;
2
+ declare class ConflictError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { conflict, ConflictError };
@@ -1 +1 @@
1
- {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/conflict.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQ5C;AAED,cAAM,aAAc,SAAQ,KAAK;gBACnB,OAAO,EAAE,MAAM;CAK5B;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/conflict.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,mCAW7B;AAED,cAAM,aAAa;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  function conflict(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 409,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 409 });
9
9
  }
10
- class ConflictError extends Error {
10
+ class ConflictError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "ConflictError";
14
15
  this.message = message;
15
16
  }
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function forbidden(error: Error): HttpResponse;
3
- declare class ForbiddenError extends Error {
1
+ declare function forbidden(error: Error): import("undici-types").Response;
2
+ declare class ForbiddenError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { forbidden, ForbiddenError };
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQ7C;AAED,cAAM,cAAe,SAAQ,KAAK;gBACpB,OAAO,EAAE,MAAM;CAK5B;AAED,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/forbidden.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,mCAW9B;AAED,cAAM,cAAc;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  function forbidden(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 403,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 403 });
9
9
  }
10
- class ForbiddenError extends Error {
10
+ class ForbiddenError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "ForbiddenError";
14
15
  this.message = message;
15
16
  }
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function notFound(error: Error): HttpResponse;
3
- declare class NotFoundError extends Error {
1
+ declare function notFound(error: Error): import("undici-types").Response;
2
+ declare class NotFoundError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { notFound, NotFoundError };
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQ5C;AAED,cAAM,aAAc,SAAQ,KAAK;gBACnB,OAAO,EAAE,MAAM;CAK5B;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/notFound.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,mCAW7B;AAED,cAAM,aAAa;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  function notFound(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 404,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 404 });
9
9
  }
10
- class NotFoundError extends Error {
10
+ class NotFoundError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "NotFoundError";
14
15
  this.message = message;
15
16
  }
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function serverError(error: Error): HttpResponse;
3
- declare class ServerError extends Error {
1
+ declare function serverError(error: Error): import("undici-types").Response;
2
+ declare class ServerError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { serverError, ServerError };
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQ/C;AAED,cAAM,WAAY,SAAQ,KAAK;gBACjB,OAAO,EAAE,MAAM;CAK5B;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,KAAK,mCAWhC;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,15 +1,16 @@
1
1
  function serverError(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 500,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 500 });
9
9
  }
10
- class ServerError extends Error {
10
+ class ServerError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "ServerError";
14
15
  this.message = message;
15
16
  }
@@ -1,6 +1,7 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
- declare function unauthorized(error: Error): HttpResponse;
3
- declare class UnauthorizedError extends Error {
1
+ declare function unauthorized(error: Error): import("undici-types").Response;
2
+ declare class UnauthorizedError {
3
+ name: string;
4
+ message: string;
4
5
  constructor(message: string);
5
6
  }
6
7
  export { unauthorized, UnauthorizedError };
@@ -1 +1 @@
1
- {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAS,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAQhD;AAED,cAAM,iBAAkB,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAK5B;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,iBAAS,YAAY,CAAC,KAAK,EAAE,KAAK,mCAWjC;AAED,cAAM,iBAAiB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM;CAI5B;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,15 +1,16 @@
1
1
  function unauthorized(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 401,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  cause: error.cause,
8
- };
8
+ }, { status: 401 });
9
9
  }
10
- class UnauthorizedError extends Error {
10
+ class UnauthorizedError {
11
+ name;
12
+ message;
11
13
  constructor(message) {
12
- super(message);
13
14
  this.name = "UnauthorizedError";
14
15
  this.message = message;
15
16
  }
@@ -1,12 +1,13 @@
1
- import type { HttpDataResponse } from "@arkyn/types";
2
1
  type UnprocessableEntityErrorProps = {
3
2
  data?: any;
4
3
  fieldErrors?: Record<string, string>;
5
4
  fields?: Record<string, string>;
6
5
  message?: string;
7
6
  };
8
- declare function unprocessableEntity(error: UnprocessableEntityError): HttpDataResponse;
9
- declare class UnprocessableEntityError extends Error {
7
+ declare function unprocessableEntity(error: UnprocessableEntityError): import("undici-types").Response;
8
+ declare class UnprocessableEntityError {
9
+ name: string;
10
+ message?: string;
10
11
  fieldErrors: any;
11
12
  fields: any;
12
13
  data: any;
@@ -1 +1 @@
1
- {"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,KAAK,6BAA6B,GAAG;IACnC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,wBAAwB,GAC9B,gBAAgB,CAUlB;AAED,cAAM,wBAAyB,SAAQ,KAAK;IAC1C,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;gBAEE,IAAI,EAAE,6BAA6B;CAOhD;AAED,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAC"}
1
+ {"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAAA,KAAK,6BAA6B,GAAG;IACnC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,iBAAS,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,mCAa3D;AAED,cAAM,wBAAwB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;gBAEE,IAAI,EAAE,6BAA6B;CAOhD;AAED,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  function unprocessableEntity(error) {
2
- return {
2
+ return Response.json({
3
3
  status: 400,
4
4
  success: false,
5
5
  name: error.name,
@@ -7,18 +7,20 @@ function unprocessableEntity(error) {
7
7
  data: error.data || null,
8
8
  fieldErrors: error.fieldErrors || null,
9
9
  fields: error.fields || null,
10
- };
10
+ }, { status: 400 });
11
11
  }
12
- class UnprocessableEntityError extends Error {
12
+ class UnprocessableEntityError {
13
+ name;
14
+ message;
13
15
  fieldErrors;
14
16
  fields;
15
17
  data;
16
18
  constructor(data) {
17
- super(data.message);
18
19
  this.data = data?.data || null;
19
20
  this.fieldErrors = data?.fieldErrors || null;
20
21
  this.fields = data?.fields || null;
21
22
  this.name = "UnprocessableEntity";
23
+ this.message = data?.message;
22
24
  }
23
25
  }
24
26
  export { unprocessableEntity, UnprocessableEntityError };
@@ -1,5 +1,5 @@
1
1
  declare class Created extends Response {
2
- constructor(body?: any, init?: ResponseInit);
2
+ constructor(body: any, init?: ResponseInit);
3
3
  }
4
4
  export { Created };
5
5
  //# sourceMappingURL=created.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU5C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU3C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  class Created extends Response {
2
2
  constructor(body, init) {
3
- super(body, {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 201,
6
6
  headers: {
@@ -1,5 +1,5 @@
1
1
  declare class Success extends Response {
2
- constructor(body?: any, init?: ResponseInit);
2
+ constructor(body: any, init?: ResponseInit);
3
3
  }
4
4
  export { Success };
5
5
  //# sourceMappingURL=success.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU5C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU3C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  class Success extends Response {
2
2
  constructor(body, init) {
3
- super(body, {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 200,
6
6
  headers: {
@@ -1,5 +1,5 @@
1
1
  declare class Updated extends Response {
2
- constructor(body?: any, init?: ResponseInit);
2
+ constructor(body: any, init?: ResponseInit);
3
3
  }
4
4
  export { Updated };
5
5
  //# sourceMappingURL=updated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU5C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAU3C;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  class Updated extends Response {
2
2
  constructor(body, init) {
3
- super(body, {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 200,
6
6
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "1.4.30",
3
+ "version": "1.4.32",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function badRequest(error: Error): HttpResponse {
4
- return {
5
- status: 400,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function badRequest(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 400,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 400 }
11
+ );
11
12
  }
12
13
 
13
- class BadRequestError extends Error {
14
+ class BadRequestError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "BadRequestError";
17
20
  this.message = message;
18
21
  }
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function conflict(error: Error): HttpResponse {
4
- return {
5
- status: 409,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function conflict(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 409,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 409 }
11
+ );
11
12
  }
12
13
 
13
- class ConflictError extends Error {
14
+ class ConflictError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "ConflictError";
17
20
  this.message = message;
18
21
  }
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function forbidden(error: Error): HttpResponse {
4
- return {
5
- status: 403,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function forbidden(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 403,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 403 }
11
+ );
11
12
  }
12
13
 
13
- class ForbiddenError extends Error {
14
+ class ForbiddenError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "ForbiddenError";
17
20
  this.message = message;
18
21
  }
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function notFound(error: Error): HttpResponse {
4
- return {
5
- status: 404,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function notFound(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 404,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 404 }
11
+ );
11
12
  }
12
13
 
13
- class NotFoundError extends Error {
14
+ class NotFoundError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "NotFoundError";
17
20
  this.message = message;
18
21
  }
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function serverError(error: Error): HttpResponse {
4
- return {
5
- status: 500,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function serverError(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 500,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 500 }
11
+ );
11
12
  }
12
13
 
13
- class ServerError extends Error {
14
+ class ServerError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "ServerError";
17
20
  this.message = message;
18
21
  }
@@ -1,18 +1,21 @@
1
- import type { HttpResponse } from "@arkyn/types";
2
-
3
- function unauthorized(error: Error): HttpResponse {
4
- return {
5
- status: 401,
6
- success: false,
7
- name: error.name,
8
- message: error.message,
9
- cause: error.cause,
10
- };
1
+ function unauthorized(error: Error) {
2
+ return Response.json(
3
+ {
4
+ status: 401,
5
+ success: false,
6
+ name: error.name,
7
+ message: error.message,
8
+ cause: error.cause,
9
+ },
10
+ { status: 401 }
11
+ );
11
12
  }
12
13
 
13
- class UnauthorizedError extends Error {
14
+ class UnauthorizedError {
15
+ name: string;
16
+ message: string;
17
+
14
18
  constructor(message: string) {
15
- super(message);
16
19
  this.name = "UnauthorizedError";
17
20
  this.message = message;
18
21
  }
@@ -1,5 +1,3 @@
1
- import type { HttpDataResponse } from "@arkyn/types";
2
-
3
1
  type UnprocessableEntityErrorProps = {
4
2
  data?: any;
5
3
  fieldErrors?: Record<string, string>;
@@ -7,31 +5,34 @@ type UnprocessableEntityErrorProps = {
7
5
  message?: string;
8
6
  };
9
7
 
10
- function unprocessableEntity(
11
- error: UnprocessableEntityError
12
- ): HttpDataResponse {
13
- return {
14
- status: 400,
15
- success: false,
16
- name: error.name,
17
- message: error.message,
18
- data: error.data || null,
19
- fieldErrors: error.fieldErrors || null,
20
- fields: error.fields || null,
21
- };
8
+ function unprocessableEntity(error: UnprocessableEntityError) {
9
+ return Response.json(
10
+ {
11
+ status: 400,
12
+ success: false,
13
+ name: error.name,
14
+ message: error.message,
15
+ data: error.data || null,
16
+ fieldErrors: error.fieldErrors || null,
17
+ fields: error.fields || null,
18
+ },
19
+ { status: 400 }
20
+ );
22
21
  }
23
22
 
24
- class UnprocessableEntityError extends Error {
23
+ class UnprocessableEntityError {
24
+ name: string;
25
+ message?: string;
25
26
  fieldErrors: any;
26
27
  fields: any;
27
28
  data: any;
28
29
 
29
30
  constructor(data: UnprocessableEntityErrorProps) {
30
- super(data.message);
31
31
  this.data = data?.data || null;
32
32
  this.fieldErrors = data?.fieldErrors || null;
33
33
  this.fields = data?.fields || null;
34
34
  this.name = "UnprocessableEntity";
35
+ this.message = data?.message;
35
36
  }
36
37
  }
37
38
 
@@ -1,6 +1,6 @@
1
1
  class Created extends Response {
2
- constructor(body?: any, init?: ResponseInit) {
3
- super(body, {
2
+ constructor(body: any, init?: ResponseInit) {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 201,
6
6
  headers: {
@@ -1,6 +1,6 @@
1
1
  class Success extends Response {
2
- constructor(body?: any, init?: ResponseInit) {
3
- super(body, {
2
+ constructor(body: any, init?: ResponseInit) {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 200,
6
6
  headers: {
@@ -1,6 +1,6 @@
1
1
  class Updated extends Response {
2
- constructor(body?: any, init?: ResponseInit) {
3
- super(body, {
2
+ constructor(body: any, init?: ResponseInit) {
3
+ super(JSON.stringify(body), {
4
4
  ...init,
5
5
  status: 200,
6
6
  headers: {