@arkyn/server 1.4.32 → 1.4.34
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.map +1 -1
- package/dist/helpers/globalErrorHandler.js +24 -3
- package/dist/httpBadResponses/badRequest.d.ts +1 -1
- package/dist/httpBadResponses/badRequest.d.ts.map +1 -1
- package/dist/httpBadResponses/badRequest.js +0 -1
- package/dist/httpBadResponses/conflict.d.ts +1 -1
- package/dist/httpBadResponses/conflict.d.ts.map +1 -1
- package/dist/httpBadResponses/conflict.js +0 -1
- package/dist/httpBadResponses/forbidden.d.ts +1 -1
- package/dist/httpBadResponses/forbidden.d.ts.map +1 -1
- package/dist/httpBadResponses/forbidden.js +0 -1
- package/dist/httpBadResponses/notFound.d.ts +1 -1
- package/dist/httpBadResponses/notFound.d.ts.map +1 -1
- package/dist/httpBadResponses/notFound.js +0 -1
- package/dist/httpBadResponses/unauthorized.d.ts +1 -1
- package/dist/httpBadResponses/unauthorized.d.ts.map +1 -1
- package/dist/httpBadResponses/unauthorized.js +0 -1
- package/dist/httpResponses/created.d.ts +5 -2
- package/dist/httpResponses/created.d.ts.map +1 -1
- package/dist/httpResponses/created.js +9 -10
- package/dist/httpResponses/noContent.d.ts +4 -2
- package/dist/httpResponses/noContent.d.ts.map +1 -1
- package/dist/httpResponses/noContent.js +7 -3
- package/dist/httpResponses/success.d.ts +5 -2
- package/dist/httpResponses/success.d.ts.map +1 -1
- package/dist/httpResponses/success.js +9 -10
- package/dist/httpResponses/updated.d.ts +5 -2
- package/dist/httpResponses/updated.d.ts.map +1 -1
- package/dist/httpResponses/updated.js +9 -10
- package/package.json +1 -1
- package/src/helpers/globalErrorHandler.ts +29 -5
- package/src/httpBadResponses/badRequest.ts +1 -2
- package/src/httpBadResponses/conflict.ts +1 -2
- package/src/httpBadResponses/forbidden.ts +1 -2
- package/src/httpBadResponses/notFound.ts +1 -2
- package/src/httpBadResponses/unauthorized.ts +1 -2
- package/src/httpResponses/created.ts +11 -10
- package/src/httpResponses/noContent.ts +9 -3
- package/src/httpResponses/success.ts +11 -10
- package/src/httpResponses/updated.ts +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalErrorHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/globalErrorHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"globalErrorHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/globalErrorHandler.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,kBAAkB,UAAW,GAAG,oCA2CrC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -3,11 +3,32 @@ import { conflict, ConflictError } from "../httpBadResponses/conflict";
|
|
|
3
3
|
import { forbidden, ForbiddenError } from "../httpBadResponses/forbidden";
|
|
4
4
|
import { notFound, NotFoundError } from "../httpBadResponses/notFound";
|
|
5
5
|
import { serverError } from "../httpBadResponses/serverError";
|
|
6
|
-
import { UnprocessableEntityError, unprocessableEntity, } from "../httpBadResponses/unprocessableEntity";
|
|
7
6
|
import { unauthorized, UnauthorizedError, } from "../httpBadResponses/unauthorized";
|
|
7
|
+
import { unprocessableEntity, UnprocessableEntityError, } from "../httpBadResponses/unprocessableEntity";
|
|
8
|
+
import { created, Created } from "../httpResponses/created";
|
|
9
|
+
import { noContent, NoContent } from "../httpResponses/noContent";
|
|
10
|
+
import { success, Success } from "../httpResponses/success";
|
|
11
|
+
import { updated, Updated } from "../httpResponses/updated";
|
|
8
12
|
const globalErrorHandler = (error) => {
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
// If the error is not an instance of Error, return the response
|
|
14
|
+
switch (true) {
|
|
15
|
+
case error instanceof Response:
|
|
16
|
+
return error;
|
|
17
|
+
case error instanceof Created:
|
|
18
|
+
return created(error.body, error.init);
|
|
19
|
+
case error instanceof Updated:
|
|
20
|
+
return updated(error.body, error.init);
|
|
21
|
+
case error instanceof Success:
|
|
22
|
+
return success(error.body, error.init);
|
|
23
|
+
case error instanceof NoContent:
|
|
24
|
+
return noContent(error.init);
|
|
25
|
+
}
|
|
26
|
+
const showConsoleError = process.env.NODE_ENV === "development" ||
|
|
27
|
+
process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
|
|
28
|
+
// If showConsoleError is true, log the error to the console
|
|
29
|
+
if (showConsoleError)
|
|
30
|
+
console.error(error);
|
|
31
|
+
// If the error is an instance of BadRequestError, ForbiddenError, ConflictError, UnauthorizedError, NotFoundError, or UnprocessableEntityError, return the error
|
|
11
32
|
switch (true) {
|
|
12
33
|
case error instanceof BadRequestError:
|
|
13
34
|
return badRequest(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/badRequest.ts"],"names":[],"mappings":"AAAA,iBAAS,UAAU,CAAC,KAAK,EAAE,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/conflict.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/forbidden.ts"],"names":[],"mappings":"AAAA,iBAAS,SAAS,CAAC,KAAK,EAAE,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/notFound.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,KAAK,EAAE,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/httpBadResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,iBAAS,YAAY,CAAC,KAAK,EAAE,
|
|
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,5 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function created(body: any, init?: ResponseInit): Response;
|
|
2
|
+
declare class Created {
|
|
3
|
+
body: any;
|
|
4
|
+
init: ResponseInit;
|
|
2
5
|
constructor(body: any, init?: ResponseInit);
|
|
3
6
|
}
|
|
4
|
-
export { Created };
|
|
7
|
+
export { created, Created };
|
|
5
8
|
//# sourceMappingURL=created.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/httpResponses/created.ts"],"names":[],"mappings":"AAAA,
|
|
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,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
function created(body, init) {
|
|
2
|
+
return Response.json(body, { ...init, status: 201 });
|
|
3
|
+
}
|
|
4
|
+
class Created {
|
|
5
|
+
body;
|
|
6
|
+
init;
|
|
2
7
|
constructor(body, init) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 201,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
8
|
+
this.body = body;
|
|
9
|
+
this.init = init || {};
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
export { Created };
|
|
12
|
+
export { created, Created };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function noContent(init?: ResponseInit): Response;
|
|
2
|
+
declare class NoContent {
|
|
3
|
+
init: ResponseInit;
|
|
2
4
|
constructor(init?: ResponseInit);
|
|
3
5
|
}
|
|
4
|
-
export { NoContent };
|
|
6
|
+
export { noContent, NoContent };
|
|
5
7
|
//# sourceMappingURL=noContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../src/httpResponses/noContent.ts"],"names":[],"mappings":"AAAA,
|
|
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,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function noContent(init) {
|
|
2
|
+
return new Response(null, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
class NoContent {
|
|
5
|
+
init;
|
|
2
6
|
constructor(init) {
|
|
3
|
-
|
|
7
|
+
this.init = init || {};
|
|
4
8
|
}
|
|
5
9
|
}
|
|
6
|
-
export { NoContent };
|
|
10
|
+
export { noContent, NoContent };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function success(body: any, init?: ResponseInit): Response;
|
|
2
|
+
declare class Success {
|
|
3
|
+
body: any;
|
|
4
|
+
init: ResponseInit;
|
|
2
5
|
constructor(body: any, init?: ResponseInit);
|
|
3
6
|
}
|
|
4
|
-
export { Success };
|
|
7
|
+
export { success, Success };
|
|
5
8
|
//# sourceMappingURL=success.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../src/httpResponses/success.ts"],"names":[],"mappings":"AAAA,
|
|
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,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
function success(body, init) {
|
|
2
|
+
return Response.json(body, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
class Success {
|
|
5
|
+
body;
|
|
6
|
+
init;
|
|
2
7
|
constructor(body, init) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 200,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
8
|
+
this.body = body;
|
|
9
|
+
this.init = init || {};
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
export { Success };
|
|
12
|
+
export { success, Success };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function updated(body: any, init?: ResponseInit): Response;
|
|
2
|
+
declare class Updated {
|
|
3
|
+
body: any;
|
|
4
|
+
init: ResponseInit;
|
|
2
5
|
constructor(body: any, init?: ResponseInit);
|
|
3
6
|
}
|
|
4
|
-
export { Updated };
|
|
7
|
+
export { updated, Updated };
|
|
5
8
|
//# sourceMappingURL=updated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../src/httpResponses/updated.ts"],"names":[],"mappings":"AAAA,
|
|
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,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
function updated(body, init) {
|
|
2
|
+
return Response.json(body, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
class Updated {
|
|
5
|
+
body;
|
|
6
|
+
init;
|
|
2
7
|
constructor(body, init) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 200,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
8
|
+
this.body = body;
|
|
9
|
+
this.init = init || {};
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
export { Updated };
|
|
12
|
+
export { updated, Updated };
|
package/package.json
CHANGED
|
@@ -3,18 +3,42 @@ import { conflict, ConflictError } from "../httpBadResponses/conflict";
|
|
|
3
3
|
import { forbidden, ForbiddenError } from "../httpBadResponses/forbidden";
|
|
4
4
|
import { notFound, NotFoundError } from "../httpBadResponses/notFound";
|
|
5
5
|
import { serverError } from "../httpBadResponses/serverError";
|
|
6
|
-
import {
|
|
7
|
-
UnprocessableEntityError,
|
|
8
|
-
unprocessableEntity,
|
|
9
|
-
} from "../httpBadResponses/unprocessableEntity";
|
|
10
6
|
import {
|
|
11
7
|
unauthorized,
|
|
12
8
|
UnauthorizedError,
|
|
13
9
|
} from "../httpBadResponses/unauthorized";
|
|
10
|
+
import {
|
|
11
|
+
unprocessableEntity,
|
|
12
|
+
UnprocessableEntityError,
|
|
13
|
+
} from "../httpBadResponses/unprocessableEntity";
|
|
14
|
+
import { created, Created } from "../httpResponses/created";
|
|
15
|
+
import { noContent, NoContent } from "../httpResponses/noContent";
|
|
16
|
+
import { success, Success } from "../httpResponses/success";
|
|
17
|
+
import { updated, Updated } from "../httpResponses/updated";
|
|
14
18
|
|
|
15
19
|
const globalErrorHandler = (error: any) => {
|
|
16
|
-
|
|
20
|
+
// If the error is not an instance of Error, return the response
|
|
21
|
+
switch (true) {
|
|
22
|
+
case error instanceof Response:
|
|
23
|
+
return error;
|
|
24
|
+
case error instanceof Created:
|
|
25
|
+
return created(error.body, error.init);
|
|
26
|
+
case error instanceof Updated:
|
|
27
|
+
return updated(error.body, error.init);
|
|
28
|
+
case error instanceof Success:
|
|
29
|
+
return success(error.body, error.init);
|
|
30
|
+
case error instanceof NoContent:
|
|
31
|
+
return noContent(error.init);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const showConsoleError =
|
|
35
|
+
process.env.NODE_ENV === "development" ||
|
|
36
|
+
process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
|
|
37
|
+
|
|
38
|
+
// If showConsoleError is true, log the error to the console
|
|
39
|
+
if (showConsoleError) console.error(error);
|
|
17
40
|
|
|
41
|
+
// If the error is an instance of BadRequestError, ForbiddenError, ConflictError, UnauthorizedError, NotFoundError, or UnprocessableEntityError, return the error
|
|
18
42
|
switch (true) {
|
|
19
43
|
case error instanceof BadRequestError:
|
|
20
44
|
return badRequest(error);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
function created(body: any, init?: ResponseInit): Response {
|
|
2
|
+
return Response.json(body, { ...init, status: 201 });
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class Created {
|
|
6
|
+
body: any;
|
|
7
|
+
init: ResponseInit;
|
|
8
|
+
|
|
2
9
|
constructor(body: any, init?: ResponseInit) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 201,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.init = init || {};
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export { Created };
|
|
15
|
+
export { created, Created };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
function noContent(init?: ResponseInit): Response {
|
|
2
|
+
return new Response(null, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class NoContent {
|
|
6
|
+
init: ResponseInit;
|
|
7
|
+
|
|
2
8
|
constructor(init?: ResponseInit) {
|
|
3
|
-
|
|
9
|
+
this.init = init || {};
|
|
4
10
|
}
|
|
5
11
|
}
|
|
6
12
|
|
|
7
|
-
export { NoContent };
|
|
13
|
+
export { noContent, NoContent };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
function success(body: any, init?: ResponseInit): Response {
|
|
2
|
+
return Response.json(body, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class Success {
|
|
6
|
+
body: any;
|
|
7
|
+
init: ResponseInit;
|
|
8
|
+
|
|
2
9
|
constructor(body: any, init?: ResponseInit) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 200,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.init = init || {};
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export { Success };
|
|
15
|
+
export { success, Success };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
function updated(body: any, init?: ResponseInit): Response {
|
|
2
|
+
return Response.json(body, { ...init, status: 200 });
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class Updated {
|
|
6
|
+
body: any;
|
|
7
|
+
init: ResponseInit;
|
|
8
|
+
|
|
2
9
|
constructor(body: any, init?: ResponseInit) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status: 200,
|
|
6
|
-
headers: {
|
|
7
|
-
"Content-Type": "application/json",
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.init = init || {};
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export { Updated };
|
|
15
|
+
export { updated, Updated };
|