@arkyn/server 1.4.34 → 1.4.36

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 (34) hide show
  1. package/dist/httpBadResponses/badRequest.d.ts.map +1 -1
  2. package/dist/httpBadResponses/badRequest.js +6 -2
  3. package/dist/httpBadResponses/conflict.d.ts.map +1 -1
  4. package/dist/httpBadResponses/conflict.js +6 -2
  5. package/dist/httpBadResponses/forbidden.d.ts.map +1 -1
  6. package/dist/httpBadResponses/forbidden.js +6 -2
  7. package/dist/httpBadResponses/notFound.d.ts.map +1 -1
  8. package/dist/httpBadResponses/notFound.js +6 -2
  9. package/dist/httpBadResponses/serverError.d.ts.map +1 -1
  10. package/dist/httpBadResponses/serverError.js +6 -3
  11. package/dist/httpBadResponses/unauthorized.d.ts.map +1 -1
  12. package/dist/httpBadResponses/unauthorized.js +6 -2
  13. package/dist/httpBadResponses/unprocessableEntity.d.ts.map +1 -1
  14. package/dist/httpBadResponses/unprocessableEntity.js +7 -3
  15. package/dist/httpResponses/created.d.ts.map +1 -1
  16. package/dist/httpResponses/created.js +5 -1
  17. package/dist/httpResponses/noContent.d.ts.map +1 -1
  18. package/dist/httpResponses/noContent.js +5 -1
  19. package/dist/httpResponses/success.d.ts.map +1 -1
  20. package/dist/httpResponses/success.js +5 -1
  21. package/dist/httpResponses/updated.d.ts.map +1 -1
  22. package/dist/httpResponses/updated.js +5 -1
  23. package/package.json +1 -1
  24. package/src/httpBadResponses/badRequest.ts +8 -4
  25. package/src/httpBadResponses/conflict.ts +8 -4
  26. package/src/httpBadResponses/forbidden.ts +8 -4
  27. package/src/httpBadResponses/notFound.ts +8 -4
  28. package/src/httpBadResponses/serverError.ts +8 -5
  29. package/src/httpBadResponses/unauthorized.ts +8 -4
  30. package/src/httpBadResponses/unprocessableEntity.ts +9 -5
  31. package/src/httpResponses/created.ts +5 -1
  32. package/src/httpResponses/noContent.ts +5 -1
  33. package/src/httpResponses/success.ts +5 -1
  34. package/src/httpResponses/updated.ts +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/badRequest.ts"],"names":[],"mappings":"AAAA,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,mCAUzC;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
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/badRequest.ts"],"names":[],"mappings":"AAAA,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,mCAczC;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,10 +1,14 @@
1
1
  function badRequest(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 400,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- }, { status: 400 });
7
+ }), {
8
+ status: 400,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
8
12
  }
9
13
  class BadRequestError {
10
14
  name;
@@ -1 +1 @@
1
- {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/conflict.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,mCAUrC;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
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/conflict.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,mCAcrC;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,10 +1,14 @@
1
1
  function conflict(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 409,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- }, { status: 409 });
7
+ }), {
8
+ status: 409,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
8
12
  }
9
13
  class ConflictError {
10
14
  name;
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/forbidden.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,mCAUvC;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
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/forbidden.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,mCAcvC;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,10 +1,14 @@
1
1
  function forbidden(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 403,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- }, { status: 403 });
7
+ }), {
8
+ status: 403,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
8
12
  }
9
13
  class ForbiddenError {
10
14
  name;
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/notFound.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,mCAUrC;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
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/notFound.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,mCAcrC;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,10 +1,14 @@
1
1
  function notFound(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 404,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- }, { status: 404 });
7
+ }), {
8
+ status: 404,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
8
12
  }
9
13
  class NotFoundError {
10
14
  name;
@@ -1 +1 @@
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
+ {"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,11 +1,14 @@
1
1
  function serverError(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 500,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- cause: error.cause,
8
- }, { status: 500 });
7
+ }), {
8
+ status: 500,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
9
12
  }
10
13
  class ServerError {
11
14
  name;
@@ -1 +1 @@
1
- {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,mCAU7C;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
+ {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,mCAc7C;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,10 +1,14 @@
1
1
  function unauthorized(error) {
2
- return Response.json({
2
+ return new Response(JSON.stringify({
3
3
  status: 401,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
- }, { status: 401 });
7
+ }), {
8
+ status: 401,
9
+ statusText: "Bad Request",
10
+ headers: { "Content-Type": "application/json" },
11
+ });
8
12
  }
9
13
  class UnauthorizedError {
10
14
  name;
@@ -1 +1 @@
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
+ {"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,mCAiB3D;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,13 +1,17 @@
1
1
  function unprocessableEntity(error) {
2
- return Response.json({
3
- status: 400,
2
+ return new Response(JSON.stringify({
3
+ status: 433,
4
4
  success: false,
5
5
  name: error.name,
6
6
  message: error.message,
7
7
  data: error.data || null,
8
8
  fieldErrors: error.fieldErrors || null,
9
9
  fields: error.fields || null,
10
- }, { status: 400 });
10
+ }), {
11
+ status: 433,
12
+ statusText: "Bad Request",
13
+ headers: { "Content-Type": "application/json" },
14
+ });
11
15
  }
12
16
  class UnprocessableEntityError {
13
17
  name;
@@ -1 +1 @@
1
- {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAMzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,5 +1,9 @@
1
1
  function created(body, init) {
2
- return Response.json(body, { ...init, status: 201 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 201,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
  class Created {
5
9
  body;
@@ -1 +1 @@
1
- {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../src/httpResponses/noContent.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEhD;AAED,cAAM,SAAS;IACb,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,CAAC,EAAE,YAAY;CAGhC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../src/httpResponses/noContent.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAMhD;AAED,cAAM,SAAS;IACb,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,CAAC,EAAE,YAAY;CAGhC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
@@ -1,5 +1,9 @@
1
1
  function noContent(init) {
2
- return new Response(null, { ...init, status: 200 });
2
+ return new Response(null, {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
  class NoContent {
5
9
  init;
@@ -1 +1 @@
1
- {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAMzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,5 +1,9 @@
1
1
  function success(body, init) {
2
- return Response.json(body, { ...init, status: 200 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
  class Success {
5
9
  body;
@@ -1 +1 @@
1
- {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,iBAAS,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAMzD;AAED,cAAM,OAAO;IACX,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;gBAEP,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,YAAY;CAI3C;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,5 +1,9 @@
1
1
  function updated(body, init) {
2
- return Response.json(body, { ...init, status: 200 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
  class Updated {
5
9
  body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "1.4.34",
3
+ "version": "1.4.36",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -1,12 +1,16 @@
1
1
  function badRequest(error: BadRequestError) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 400,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- },
9
- { status: 400 }
8
+ }),
9
+ {
10
+ status: 400,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
10
14
  );
11
15
  }
12
16
 
@@ -1,12 +1,16 @@
1
1
  function conflict(error: ConflictError) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 409,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- },
9
- { status: 409 }
8
+ }),
9
+ {
10
+ status: 409,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
10
14
  );
11
15
  }
12
16
 
@@ -1,12 +1,16 @@
1
1
  function forbidden(error: ForbiddenError) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 403,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- },
9
- { status: 403 }
8
+ }),
9
+ {
10
+ status: 403,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
10
14
  );
11
15
  }
12
16
 
@@ -1,12 +1,16 @@
1
1
  function notFound(error: NotFoundError) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 404,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- },
9
- { status: 404 }
8
+ }),
9
+ {
10
+ status: 404,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
10
14
  );
11
15
  }
12
16
 
@@ -1,13 +1,16 @@
1
1
  function serverError(error: Error) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 500,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- cause: error.cause,
9
- },
10
- { status: 500 }
8
+ }),
9
+ {
10
+ status: 500,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
11
14
  );
12
15
  }
13
16
 
@@ -1,12 +1,16 @@
1
1
  function unauthorized(error: UnauthorizedError) {
2
- return Response.json(
3
- {
2
+ return new Response(
3
+ JSON.stringify({
4
4
  status: 401,
5
5
  success: false,
6
6
  name: error.name,
7
7
  message: error.message,
8
- },
9
- { status: 401 }
8
+ }),
9
+ {
10
+ status: 401,
11
+ statusText: "Bad Request",
12
+ headers: { "Content-Type": "application/json" },
13
+ }
10
14
  );
11
15
  }
12
16
 
@@ -6,17 +6,21 @@ type UnprocessableEntityErrorProps = {
6
6
  };
7
7
 
8
8
  function unprocessableEntity(error: UnprocessableEntityError) {
9
- return Response.json(
10
- {
11
- status: 400,
9
+ return new Response(
10
+ JSON.stringify({
11
+ status: 433,
12
12
  success: false,
13
13
  name: error.name,
14
14
  message: error.message,
15
15
  data: error.data || null,
16
16
  fieldErrors: error.fieldErrors || null,
17
17
  fields: error.fields || null,
18
- },
19
- { status: 400 }
18
+ }),
19
+ {
20
+ status: 433,
21
+ statusText: "Bad Request",
22
+ headers: { "Content-Type": "application/json" },
23
+ }
20
24
  );
21
25
  }
22
26
 
@@ -1,5 +1,9 @@
1
1
  function created(body: any, init?: ResponseInit): Response {
2
- return Response.json(body, { ...init, status: 201 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 201,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
 
5
9
  class Created {
@@ -1,5 +1,9 @@
1
1
  function noContent(init?: ResponseInit): Response {
2
- return new Response(null, { ...init, status: 200 });
2
+ return new Response(null, {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
 
5
9
  class NoContent {
@@ -1,5 +1,9 @@
1
1
  function success(body: any, init?: ResponseInit): Response {
2
- return Response.json(body, { ...init, status: 200 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
 
5
9
  class Success {
@@ -1,5 +1,9 @@
1
1
  function updated(body: any, init?: ResponseInit): Response {
2
- return Response.json(body, { ...init, status: 200 });
2
+ return new Response(JSON.stringify(body), {
3
+ ...init,
4
+ status: 200,
5
+ headers: { "Content-Type": "application/json", ...init?.headers },
6
+ });
3
7
  }
4
8
 
5
9
  class Updated {