@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.
- package/dist/helpers/globalErrorHandler.d.ts +1 -1
- package/dist/helpers/globalErrorHandler.d.ts.map +1 -1
- package/dist/httpBadResponses/badRequest.d.ts +4 -3
- package/dist/httpBadResponses/badRequest.d.ts.map +1 -1
- package/dist/httpBadResponses/badRequest.js +5 -4
- package/dist/httpBadResponses/conflict.d.ts +4 -3
- package/dist/httpBadResponses/conflict.d.ts.map +1 -1
- package/dist/httpBadResponses/conflict.js +5 -4
- package/dist/httpBadResponses/forbidden.d.ts +4 -3
- package/dist/httpBadResponses/forbidden.d.ts.map +1 -1
- package/dist/httpBadResponses/forbidden.js +5 -4
- package/dist/httpBadResponses/notFound.d.ts +4 -3
- package/dist/httpBadResponses/notFound.d.ts.map +1 -1
- package/dist/httpBadResponses/notFound.js +5 -4
- package/dist/httpBadResponses/serverError.d.ts +4 -3
- package/dist/httpBadResponses/serverError.d.ts.map +1 -1
- package/dist/httpBadResponses/serverError.js +5 -4
- package/dist/httpBadResponses/unauthorized.d.ts +4 -3
- package/dist/httpBadResponses/unauthorized.d.ts.map +1 -1
- package/dist/httpBadResponses/unauthorized.js +5 -4
- package/dist/httpBadResponses/unprocessableEntity.d.ts +4 -3
- package/dist/httpBadResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/httpBadResponses/unprocessableEntity.js +6 -4
- package/dist/httpResponses/created.d.ts +1 -1
- package/dist/httpResponses/created.d.ts.map +1 -1
- package/dist/httpResponses/created.js +1 -1
- package/dist/httpResponses/success.d.ts +1 -1
- package/dist/httpResponses/success.d.ts.map +1 -1
- package/dist/httpResponses/success.js +1 -1
- package/dist/httpResponses/updated.d.ts +1 -1
- package/dist/httpResponses/updated.d.ts.map +1 -1
- package/dist/httpResponses/updated.js +1 -1
- package/package.json +1 -1
- package/src/httpBadResponses/badRequest.ts +15 -12
- package/src/httpBadResponses/conflict.ts +15 -12
- package/src/httpBadResponses/forbidden.ts +15 -12
- package/src/httpBadResponses/notFound.ts +15 -12
- package/src/httpBadResponses/serverError.ts +15 -12
- package/src/httpBadResponses/unauthorized.ts +15 -12
- package/src/httpBadResponses/unprocessableEntity.ts +17 -16
- package/src/httpResponses/created.ts +2 -2
- package/src/httpResponses/success.ts +2 -2
- package/src/httpResponses/updated.ts +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const globalErrorHandler: (error: any) => import("
|
|
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,
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
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,
|
|
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
|
|
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):
|
|
9
|
-
declare class UnprocessableEntityError
|
|
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,
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,cAAM,OAAQ,SAAQ,QAAQ;gBAChB,IAAI,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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
|
|