@arkyn/server 2.0.1-beta.1 → 2.0.1-beta.3

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 (136) hide show
  1. package/dist/http/badResponses/badGateway.d.ts +11 -0
  2. package/dist/http/badResponses/badGateway.d.ts.map +1 -0
  3. package/dist/http/badResponses/badGateway.js +29 -0
  4. package/dist/http/badResponses/badRequest.d.ts +11 -0
  5. package/dist/http/badResponses/badRequest.d.ts.map +1 -0
  6. package/dist/http/badResponses/badRequest.js +29 -0
  7. package/dist/http/badResponses/conflict.d.ts +11 -0
  8. package/dist/http/badResponses/conflict.d.ts.map +1 -0
  9. package/dist/http/badResponses/conflict.js +29 -0
  10. package/dist/http/badResponses/forbidden.d.ts +11 -0
  11. package/dist/http/badResponses/forbidden.d.ts.map +1 -0
  12. package/dist/http/badResponses/forbidden.js +29 -0
  13. package/dist/http/badResponses/notFound.d.ts +11 -0
  14. package/dist/http/badResponses/notFound.d.ts.map +1 -0
  15. package/dist/http/badResponses/notFound.js +29 -0
  16. package/dist/http/badResponses/notImplemented.d.ts +11 -0
  17. package/dist/http/badResponses/notImplemented.d.ts.map +1 -0
  18. package/dist/http/badResponses/notImplemented.js +29 -0
  19. package/dist/http/badResponses/serverError.d.ts +11 -0
  20. package/dist/http/badResponses/serverError.d.ts.map +1 -0
  21. package/dist/http/badResponses/serverError.js +29 -0
  22. package/dist/http/badResponses/unauthorized.d.ts +11 -0
  23. package/dist/http/badResponses/unauthorized.d.ts.map +1 -0
  24. package/dist/http/badResponses/unauthorized.js +29 -0
  25. package/dist/http/badResponses/unprocessableEntity.d.ts +16 -0
  26. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -0
  27. package/dist/http/badResponses/unprocessableEntity.js +33 -0
  28. package/dist/http/httpDebug.d.ts +3 -0
  29. package/dist/http/httpDebug.d.ts.map +1 -0
  30. package/dist/http/httpDebug.js +15 -0
  31. package/dist/http/successResponses/created.d.ts +11 -0
  32. package/dist/http/successResponses/created.d.ts.map +1 -0
  33. package/dist/http/successResponses/created.js +29 -0
  34. package/dist/http/successResponses/found.d.ts +11 -0
  35. package/dist/http/successResponses/found.d.ts.map +1 -0
  36. package/dist/http/successResponses/found.js +29 -0
  37. package/dist/http/successResponses/noContent.d.ts +10 -0
  38. package/dist/http/successResponses/noContent.d.ts.map +1 -0
  39. package/dist/http/successResponses/noContent.js +27 -0
  40. package/dist/http/successResponses/success.d.ts +11 -0
  41. package/dist/http/successResponses/success.d.ts.map +1 -0
  42. package/dist/http/successResponses/success.js +29 -0
  43. package/dist/http/successResponses/updated.d.ts +11 -0
  44. package/dist/http/successResponses/updated.d.ts.map +1 -0
  45. package/dist/http/successResponses/updated.js +29 -0
  46. package/dist/index.d.ts +16 -13
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +16 -17
  49. package/dist/services/decodeRequestBody.d.ts +17 -0
  50. package/dist/services/decodeRequestBody.d.ts.map +1 -0
  51. package/dist/services/{extractJsonFromRequest.js → decodeRequestBody.js} +16 -3
  52. package/dist/services/errorHandler.d.ts +3 -0
  53. package/dist/services/errorHandler.d.ts.map +1 -0
  54. package/dist/services/errorHandler.js +51 -0
  55. package/dist/services/formParse.d.ts +40 -1
  56. package/dist/services/formParse.d.ts.map +1 -1
  57. package/dist/services/formParse.js +40 -1
  58. package/dist/services/getScopedParams.d.ts +26 -1
  59. package/dist/services/getScopedParams.d.ts.map +1 -1
  60. package/dist/services/getScopedParams.js +26 -2
  61. package/dist/services/sendFileToS3.d.ts +50 -18
  62. package/dist/services/sendFileToS3.d.ts.map +1 -1
  63. package/dist/services/sendFileToS3.js +73 -31
  64. package/package.json +2 -1
  65. package/src/http/badResponses/badGateway.ts +36 -0
  66. package/src/http/badResponses/badRequest.ts +36 -0
  67. package/src/http/badResponses/conflict.ts +36 -0
  68. package/src/http/badResponses/forbidden.ts +36 -0
  69. package/src/http/badResponses/notFound.ts +36 -0
  70. package/src/http/badResponses/notImplemented.ts +36 -0
  71. package/src/http/badResponses/serverError.ts +36 -0
  72. package/src/http/badResponses/unauthorized.ts +36 -0
  73. package/src/http/badResponses/unprocessableEntity.ts +48 -0
  74. package/src/http/httpDebug.ts +31 -0
  75. package/src/http/successResponses/created.ts +35 -0
  76. package/src/http/successResponses/found.ts +35 -0
  77. package/src/http/successResponses/noContent.ts +33 -0
  78. package/src/http/successResponses/success.ts +35 -0
  79. package/src/http/successResponses/updated.ts +35 -0
  80. package/src/index.ts +16 -18
  81. package/src/services/decodeRequestBody.ts +46 -0
  82. package/src/services/errorHandler.ts +55 -0
  83. package/src/services/formParse.ts +42 -1
  84. package/src/services/getScopedParams.ts +29 -2
  85. package/src/services/sendFileToS3.ts +81 -56
  86. package/dist/helpers/globalErrorHandler.d.ts +0 -3
  87. package/dist/helpers/globalErrorHandler.d.ts.map +0 -1
  88. package/dist/helpers/globalErrorHandler.js +0 -53
  89. package/dist/httpBadResponses/badRequest.d.ts +0 -9
  90. package/dist/httpBadResponses/badRequest.d.ts.map +0 -1
  91. package/dist/httpBadResponses/badRequest.js +0 -23
  92. package/dist/httpBadResponses/conflict.d.ts +0 -9
  93. package/dist/httpBadResponses/conflict.d.ts.map +0 -1
  94. package/dist/httpBadResponses/conflict.js +0 -23
  95. package/dist/httpBadResponses/forbidden.d.ts +0 -9
  96. package/dist/httpBadResponses/forbidden.d.ts.map +0 -1
  97. package/dist/httpBadResponses/forbidden.js +0 -23
  98. package/dist/httpBadResponses/notFound.d.ts +0 -9
  99. package/dist/httpBadResponses/notFound.d.ts.map +0 -1
  100. package/dist/httpBadResponses/notFound.js +0 -23
  101. package/dist/httpBadResponses/serverError.d.ts +0 -9
  102. package/dist/httpBadResponses/serverError.d.ts.map +0 -1
  103. package/dist/httpBadResponses/serverError.js +0 -23
  104. package/dist/httpBadResponses/unauthorized.d.ts +0 -9
  105. package/dist/httpBadResponses/unauthorized.d.ts.map +0 -1
  106. package/dist/httpBadResponses/unauthorized.js +0 -23
  107. package/dist/httpBadResponses/unprocessableEntity.d.ts +0 -17
  108. package/dist/httpBadResponses/unprocessableEntity.d.ts.map +0 -1
  109. package/dist/httpBadResponses/unprocessableEntity.js +0 -30
  110. package/dist/httpResponses/created.d.ts +0 -10
  111. package/dist/httpResponses/created.d.ts.map +0 -1
  112. package/dist/httpResponses/created.js +0 -30
  113. package/dist/httpResponses/noContent.d.ts +0 -9
  114. package/dist/httpResponses/noContent.d.ts.map +0 -1
  115. package/dist/httpResponses/noContent.js +0 -28
  116. package/dist/httpResponses/success.d.ts +0 -10
  117. package/dist/httpResponses/success.d.ts.map +0 -1
  118. package/dist/httpResponses/success.js +0 -30
  119. package/dist/httpResponses/updated.d.ts +0 -10
  120. package/dist/httpResponses/updated.d.ts.map +0 -1
  121. package/dist/httpResponses/updated.js +0 -30
  122. package/dist/services/extractJsonFromRequest.d.ts +0 -3
  123. package/dist/services/extractJsonFromRequest.d.ts.map +0 -1
  124. package/src/helpers/globalErrorHandler.ts +0 -64
  125. package/src/httpBadResponses/badRequest.ts +0 -29
  126. package/src/httpBadResponses/conflict.ts +0 -29
  127. package/src/httpBadResponses/forbidden.ts +0 -29
  128. package/src/httpBadResponses/notFound.ts +0 -29
  129. package/src/httpBadResponses/serverError.ts +0 -29
  130. package/src/httpBadResponses/unauthorized.ts +0 -29
  131. package/src/httpBadResponses/unprocessableEntity.ts +0 -43
  132. package/src/httpResponses/created.ts +0 -35
  133. package/src/httpResponses/noContent.ts +0 -33
  134. package/src/httpResponses/success.ts +0 -35
  135. package/src/httpResponses/updated.ts +0 -35
  136. package/src/services/extractJsonFromRequest.ts +0 -30
@@ -0,0 +1,11 @@
1
+ declare class BadGateway {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { BadGateway };
11
+ //# sourceMappingURL=badGateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class BadGateway {
3
+ body;
4
+ cause;
5
+ status = 502;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "BadGateway", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("BadGateway", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { BadGateway };
@@ -0,0 +1,11 @@
1
+ declare class BadRequest {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { BadRequest };
11
+ //# sourceMappingURL=badRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class BadRequest {
3
+ body;
4
+ cause;
5
+ status = 400;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "BadRequest", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("BadRequest", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { BadRequest };
@@ -0,0 +1,11 @@
1
+ declare class Conflict {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Conflict };
11
+ //# sourceMappingURL=conflict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class Conflict {
3
+ body;
4
+ cause;
5
+ status = 409;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "Conflict", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("Conflict", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Conflict };
@@ -0,0 +1,11 @@
1
+ declare class Forbidden {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Forbidden };
11
+ //# sourceMappingURL=forbidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAEA,cAAM,SAAS;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class Forbidden {
3
+ body;
4
+ cause;
5
+ status = 402;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "Forbidden", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("Forbidden", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Forbidden };
@@ -0,0 +1,11 @@
1
+ declare class NotFound {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { NotFound };
11
+ //# sourceMappingURL=notFound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class NotFound {
3
+ body;
4
+ cause;
5
+ status = 404;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "NotFound", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("NotFound", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { NotFound };
@@ -0,0 +1,11 @@
1
+ declare class NotImplemented {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { NotImplemented };
11
+ //# sourceMappingURL=notImplemented.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAEA,cAAM,cAAc;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class NotImplemented {
3
+ body;
4
+ cause;
5
+ status = 501;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "NotImplemented", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("NotImplemented", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { NotImplemented };
@@ -0,0 +1,11 @@
1
+ declare class ServerError {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { ServerError };
11
+ //# sourceMappingURL=serverError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAEA,cAAM,WAAW;IACf,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class ServerError {
3
+ body;
4
+ cause;
5
+ status = 500;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "ServerError", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("ServerError", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { ServerError };
@@ -0,0 +1,11 @@
1
+ declare class Unauthorized {
2
+ body: any;
3
+ cause?: any;
4
+ status: number;
5
+ statusText: string;
6
+ constructor(message: string, cause?: any);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Unauthorized };
11
+ //# sourceMappingURL=unauthorized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAEA,cAAM,YAAY;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class Unauthorized {
3
+ body;
4
+ cause;
5
+ status = 401;
6
+ statusText;
7
+ constructor(message, cause) {
8
+ this.body = { name: "Unauthorized", message: message };
9
+ this.statusText = message;
10
+ this.cause = cause ? JSON.stringify(cause) : undefined;
11
+ httpDebug("Unauthorized", this.body, this.cause);
12
+ }
13
+ toResponse() {
14
+ const responseInit = {
15
+ headers: { "Content-Type": "application/json" },
16
+ status: this.status,
17
+ statusText: this.statusText,
18
+ };
19
+ return new Response(JSON.stringify(this.body), responseInit);
20
+ }
21
+ toJson() {
22
+ const responseInit = {
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Unauthorized };
@@ -0,0 +1,16 @@
1
+ type UnprocessableEntityProps = {
2
+ data?: any;
3
+ fieldErrors?: Record<string, string>;
4
+ fields?: Record<string, string>;
5
+ message?: string;
6
+ };
7
+ declare class UnprocessableEntity {
8
+ body: any;
9
+ status: number;
10
+ statusText: string;
11
+ constructor(props: UnprocessableEntityProps);
12
+ toResponse(): Response;
13
+ toJson(): Response;
14
+ }
15
+ export { UnprocessableEntity };
16
+ //# sourceMappingURL=unprocessableEntity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAEA,KAAK,wBAAwB,GAAG;IAC9B,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,cAAM,mBAAmB;IACvB,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEP,KAAK,EAAE,wBAAwB;IAa3C,UAAU;IAUV,MAAM;CAQP;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { httpDebug } from "../httpDebug";
2
+ class UnprocessableEntity {
3
+ body;
4
+ status = 422;
5
+ statusText;
6
+ constructor(props) {
7
+ this.statusText = props.message || "Unprocessable Entity";
8
+ this.body = {
9
+ name: "UnprocessableEntity",
10
+ message: props.message || null,
11
+ data: props.data,
12
+ fieldErrors: props.fieldErrors,
13
+ fields: props.fields,
14
+ };
15
+ httpDebug("UnprocessableEntity", this.body);
16
+ }
17
+ toResponse() {
18
+ const responseInit = {
19
+ headers: { "Content-Type": "application/json" },
20
+ status: this.status,
21
+ statusText: this.statusText,
22
+ };
23
+ return new Response(JSON.stringify(this.body), responseInit);
24
+ }
25
+ toJson() {
26
+ const responseInit = {
27
+ status: this.status,
28
+ statusText: this.statusText,
29
+ };
30
+ return Response.json(this.body, responseInit);
31
+ }
32
+ }
33
+ export { UnprocessableEntity };
@@ -0,0 +1,3 @@
1
+ declare function httpDebug(name: string, body: any, cause?: any): void;
2
+ export { httpDebug };
3
+ //# sourceMappingURL=httpDebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/http/httpDebug.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAetD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ function httpDebug(name, body, cause) {
2
+ const isDebugMode = process.env.NODE_ENV === "development" ||
3
+ process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
4
+ if (isDebugMode) {
5
+ const reset = "\x1b[0m";
6
+ const cyan = "\x1b[36m";
7
+ const pathname = new URL(import.meta.url).pathname;
8
+ console.log(`${cyan}[ARKYN-DEBUG]${reset} ${name} initialized`);
9
+ console.log(`${cyan}[ARKYN-DEBUG]${reset} Pathname:`, pathname);
10
+ console.log(`${cyan}[ARKYN-DEBUG]${reset} Body:`, body);
11
+ if (cause)
12
+ console.log(`[ARKYN-DEBUG] Cause:`, cause);
13
+ }
14
+ }
15
+ export { httpDebug };
@@ -0,0 +1,11 @@
1
+ declare class Created<T> {
2
+ body: T;
3
+ headers: ResponseInit["headers"];
4
+ status: number;
5
+ statusText: string;
6
+ constructor(body: T, init?: ResponseInit);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Created };
11
+ //# sourceMappingURL=created.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC,UAAU;IAUV,MAAM;CASP;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ class Created {
2
+ body;
3
+ headers;
4
+ status;
5
+ statusText;
6
+ constructor(body, init) {
7
+ this.body = body;
8
+ this.headers = init?.headers || {};
9
+ this.status = init?.status || 201;
10
+ this.statusText = init?.statusText || "Resource created successfully";
11
+ }
12
+ toResponse() {
13
+ const responseInit = {
14
+ headers: { "Content-Type": "application/json", ...this.headers },
15
+ status: this.status,
16
+ statusText: this.statusText,
17
+ };
18
+ return new Response(JSON.stringify(this.body), responseInit);
19
+ }
20
+ toJson() {
21
+ const responseInit = {
22
+ headers: this.headers,
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Created };
@@ -0,0 +1,11 @@
1
+ declare class Found<T> {
2
+ body: T;
3
+ headers: ResponseInit["headers"];
4
+ status: number;
5
+ statusText: string;
6
+ constructor(body: T, init?: ResponseInit);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Found };
11
+ //# sourceMappingURL=found.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA,cAAM,KAAK,CAAC,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC,UAAU;IAUV,MAAM;CASP;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ class Found {
2
+ body;
3
+ headers;
4
+ status;
5
+ statusText;
6
+ constructor(body, init) {
7
+ this.body = body;
8
+ this.headers = init?.headers || {};
9
+ this.status = init?.status || 302;
10
+ this.statusText = init?.statusText || "Found";
11
+ }
12
+ toResponse() {
13
+ const responseInit = {
14
+ headers: { "Content-Type": "application/json", ...this.headers },
15
+ status: this.status,
16
+ statusText: this.statusText,
17
+ };
18
+ return new Response(JSON.stringify(this.body), responseInit);
19
+ }
20
+ toJson() {
21
+ const responseInit = {
22
+ headers: this.headers,
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Found };
@@ -0,0 +1,10 @@
1
+ declare class NoContent {
2
+ headers: ResponseInit["headers"];
3
+ status: number;
4
+ statusText: string;
5
+ constructor(init?: ResponseInit);
6
+ toResponse(): Response;
7
+ toJson(): Response;
8
+ }
9
+ export { NoContent };
10
+ //# sourceMappingURL=noContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,cAAM,SAAS;IACb,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,CAAC,EAAE,YAAY;IAM/B,UAAU;IAUV,MAAM;CASP;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ class NoContent {
2
+ headers;
3
+ status;
4
+ statusText;
5
+ constructor(init) {
6
+ this.headers = init?.headers || {};
7
+ this.status = init?.status || 204;
8
+ this.statusText = init?.statusText ?? "No content";
9
+ }
10
+ toResponse() {
11
+ const responseInit = {
12
+ headers: this.headers,
13
+ status: this.status,
14
+ statusText: this.statusText,
15
+ };
16
+ return new Response(null, responseInit);
17
+ }
18
+ toJson() {
19
+ const responseInit = {
20
+ headers: this.headers,
21
+ status: this.status,
22
+ statusText: this.statusText,
23
+ };
24
+ return Response.json(null, responseInit);
25
+ }
26
+ }
27
+ export { NoContent };
@@ -0,0 +1,11 @@
1
+ declare class Success<T> {
2
+ body: T;
3
+ headers: ResponseInit["headers"];
4
+ status: number;
5
+ statusText: string;
6
+ constructor(body: T, init?: ResponseInit);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Success };
11
+ //# sourceMappingURL=success.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC,UAAU;IAUV,MAAM;CASP;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ class Success {
2
+ body;
3
+ headers;
4
+ status;
5
+ statusText;
6
+ constructor(body, init) {
7
+ this.body = body;
8
+ this.headers = init?.headers || {};
9
+ this.status = init?.status || 200;
10
+ this.statusText = init?.statusText ?? "OK";
11
+ }
12
+ toResponse() {
13
+ const responseInit = {
14
+ headers: { "Content-Type": "application/json", ...this.headers },
15
+ status: this.status,
16
+ statusText: this.statusText,
17
+ };
18
+ return new Response(JSON.stringify(this.body), responseInit);
19
+ }
20
+ toJson() {
21
+ const responseInit = {
22
+ headers: this.headers,
23
+ status: this.status,
24
+ statusText: this.statusText,
25
+ };
26
+ return Response.json(this.body, responseInit);
27
+ }
28
+ }
29
+ export { Success };
@@ -0,0 +1,11 @@
1
+ declare class Updated<T> {
2
+ body: T;
3
+ headers: ResponseInit["headers"];
4
+ status: number;
5
+ statusText: string;
6
+ constructor(body: T, init?: ResponseInit);
7
+ toResponse(): Response;
8
+ toJson(): Response;
9
+ }
10
+ export { Updated };
11
+ //# sourceMappingURL=updated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/updated.ts"],"names":[],"mappings":"AAAA,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC,UAAU;IAUV,MAAM;CASP;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}