@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.
- package/dist/http/badResponses/badGateway.d.ts +11 -0
- package/dist/http/badResponses/badGateway.d.ts.map +1 -0
- package/dist/http/badResponses/badGateway.js +29 -0
- package/dist/http/badResponses/badRequest.d.ts +11 -0
- package/dist/http/badResponses/badRequest.d.ts.map +1 -0
- package/dist/http/badResponses/badRequest.js +29 -0
- package/dist/http/badResponses/conflict.d.ts +11 -0
- package/dist/http/badResponses/conflict.d.ts.map +1 -0
- package/dist/http/badResponses/conflict.js +29 -0
- package/dist/http/badResponses/forbidden.d.ts +11 -0
- package/dist/http/badResponses/forbidden.d.ts.map +1 -0
- package/dist/http/badResponses/forbidden.js +29 -0
- package/dist/http/badResponses/notFound.d.ts +11 -0
- package/dist/http/badResponses/notFound.d.ts.map +1 -0
- package/dist/http/badResponses/notFound.js +29 -0
- package/dist/http/badResponses/notImplemented.d.ts +11 -0
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -0
- package/dist/http/badResponses/notImplemented.js +29 -0
- package/dist/http/badResponses/serverError.d.ts +11 -0
- package/dist/http/badResponses/serverError.d.ts.map +1 -0
- package/dist/http/badResponses/serverError.js +29 -0
- package/dist/http/badResponses/unauthorized.d.ts +11 -0
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -0
- package/dist/http/badResponses/unauthorized.js +29 -0
- package/dist/http/badResponses/unprocessableEntity.d.ts +16 -0
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -0
- package/dist/http/badResponses/unprocessableEntity.js +33 -0
- package/dist/http/httpDebug.d.ts +3 -0
- package/dist/http/httpDebug.d.ts.map +1 -0
- package/dist/http/httpDebug.js +15 -0
- package/dist/http/successResponses/created.d.ts +11 -0
- package/dist/http/successResponses/created.d.ts.map +1 -0
- package/dist/http/successResponses/created.js +29 -0
- package/dist/http/successResponses/found.d.ts +11 -0
- package/dist/http/successResponses/found.d.ts.map +1 -0
- package/dist/http/successResponses/found.js +29 -0
- package/dist/http/successResponses/noContent.d.ts +10 -0
- package/dist/http/successResponses/noContent.d.ts.map +1 -0
- package/dist/http/successResponses/noContent.js +27 -0
- package/dist/http/successResponses/success.d.ts +11 -0
- package/dist/http/successResponses/success.d.ts.map +1 -0
- package/dist/http/successResponses/success.js +29 -0
- package/dist/http/successResponses/updated.d.ts +11 -0
- package/dist/http/successResponses/updated.d.ts.map +1 -0
- package/dist/http/successResponses/updated.js +29 -0
- package/dist/index.d.ts +16 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -17
- package/dist/services/decodeRequestBody.d.ts +17 -0
- package/dist/services/decodeRequestBody.d.ts.map +1 -0
- package/dist/services/{extractJsonFromRequest.js → decodeRequestBody.js} +16 -3
- package/dist/services/errorHandler.d.ts +3 -0
- package/dist/services/errorHandler.d.ts.map +1 -0
- package/dist/services/errorHandler.js +51 -0
- package/dist/services/formParse.d.ts +40 -1
- package/dist/services/formParse.d.ts.map +1 -1
- package/dist/services/formParse.js +40 -1
- package/dist/services/getScopedParams.d.ts +26 -1
- package/dist/services/getScopedParams.d.ts.map +1 -1
- package/dist/services/getScopedParams.js +26 -2
- package/dist/services/sendFileToS3.d.ts +50 -18
- package/dist/services/sendFileToS3.d.ts.map +1 -1
- package/dist/services/sendFileToS3.js +73 -31
- package/package.json +2 -1
- package/src/http/badResponses/badGateway.ts +36 -0
- package/src/http/badResponses/badRequest.ts +36 -0
- package/src/http/badResponses/conflict.ts +36 -0
- package/src/http/badResponses/forbidden.ts +36 -0
- package/src/http/badResponses/notFound.ts +36 -0
- package/src/http/badResponses/notImplemented.ts +36 -0
- package/src/http/badResponses/serverError.ts +36 -0
- package/src/http/badResponses/unauthorized.ts +36 -0
- package/src/http/badResponses/unprocessableEntity.ts +48 -0
- package/src/http/httpDebug.ts +31 -0
- package/src/http/successResponses/created.ts +35 -0
- package/src/http/successResponses/found.ts +35 -0
- package/src/http/successResponses/noContent.ts +33 -0
- package/src/http/successResponses/success.ts +35 -0
- package/src/http/successResponses/updated.ts +35 -0
- package/src/index.ts +16 -18
- package/src/services/decodeRequestBody.ts +46 -0
- package/src/services/errorHandler.ts +55 -0
- package/src/services/formParse.ts +42 -1
- package/src/services/getScopedParams.ts +29 -2
- package/src/services/sendFileToS3.ts +81 -56
- package/dist/helpers/globalErrorHandler.d.ts +0 -3
- package/dist/helpers/globalErrorHandler.d.ts.map +0 -1
- package/dist/helpers/globalErrorHandler.js +0 -53
- package/dist/httpBadResponses/badRequest.d.ts +0 -9
- package/dist/httpBadResponses/badRequest.d.ts.map +0 -1
- package/dist/httpBadResponses/badRequest.js +0 -23
- package/dist/httpBadResponses/conflict.d.ts +0 -9
- package/dist/httpBadResponses/conflict.d.ts.map +0 -1
- package/dist/httpBadResponses/conflict.js +0 -23
- package/dist/httpBadResponses/forbidden.d.ts +0 -9
- package/dist/httpBadResponses/forbidden.d.ts.map +0 -1
- package/dist/httpBadResponses/forbidden.js +0 -23
- package/dist/httpBadResponses/notFound.d.ts +0 -9
- package/dist/httpBadResponses/notFound.d.ts.map +0 -1
- package/dist/httpBadResponses/notFound.js +0 -23
- package/dist/httpBadResponses/serverError.d.ts +0 -9
- package/dist/httpBadResponses/serverError.d.ts.map +0 -1
- package/dist/httpBadResponses/serverError.js +0 -23
- package/dist/httpBadResponses/unauthorized.d.ts +0 -9
- package/dist/httpBadResponses/unauthorized.d.ts.map +0 -1
- package/dist/httpBadResponses/unauthorized.js +0 -23
- package/dist/httpBadResponses/unprocessableEntity.d.ts +0 -17
- package/dist/httpBadResponses/unprocessableEntity.d.ts.map +0 -1
- package/dist/httpBadResponses/unprocessableEntity.js +0 -30
- package/dist/httpResponses/created.d.ts +0 -10
- package/dist/httpResponses/created.d.ts.map +0 -1
- package/dist/httpResponses/created.js +0 -30
- package/dist/httpResponses/noContent.d.ts +0 -9
- package/dist/httpResponses/noContent.d.ts.map +0 -1
- package/dist/httpResponses/noContent.js +0 -28
- package/dist/httpResponses/success.d.ts +0 -10
- package/dist/httpResponses/success.d.ts.map +0 -1
- package/dist/httpResponses/success.js +0 -30
- package/dist/httpResponses/updated.d.ts +0 -10
- package/dist/httpResponses/updated.d.ts.map +0 -1
- package/dist/httpResponses/updated.js +0 -30
- package/dist/services/extractJsonFromRequest.d.ts +0 -3
- package/dist/services/extractJsonFromRequest.d.ts.map +0 -1
- package/src/helpers/globalErrorHandler.ts +0 -64
- package/src/httpBadResponses/badRequest.ts +0 -29
- package/src/httpBadResponses/conflict.ts +0 -29
- package/src/httpBadResponses/forbidden.ts +0 -29
- package/src/httpBadResponses/notFound.ts +0 -29
- package/src/httpBadResponses/serverError.ts +0 -29
- package/src/httpBadResponses/unauthorized.ts +0 -29
- package/src/httpBadResponses/unprocessableEntity.ts +0 -43
- package/src/httpResponses/created.ts +0 -35
- package/src/httpResponses/noContent.ts +0 -33
- package/src/httpResponses/success.ts +0 -35
- package/src/httpResponses/updated.ts +0 -35
- 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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|