dn-react-router-toolkit 0.9.1 → 0.9.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/api/{create_handler.d.mts → default_api_handler.d.mts} +3 -3
- package/dist/api/{create_handler.d.ts → default_api_handler.d.ts} +3 -3
- package/dist/api/{create_handler.js → default_api_handler.js} +8 -8
- package/dist/api/{create_handler.mjs → default_api_handler.mjs} +4 -4
- package/dist/api/index.d.mts +5 -5
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +186 -116
- package/dist/api/index.mjs +192 -126
- package/dist/api/put_resource_handler.d.mts +25 -0
- package/dist/api/put_resource_handler.d.ts +25 -0
- package/dist/api/put_resource_handler.js +214 -0
- package/dist/api/put_resource_handler.mjs +194 -0
- package/dist/api/resource_handler.d.mts +26 -0
- package/dist/api/resource_handler.d.ts +26 -0
- package/dist/api/resource_handler.js +280 -0
- package/dist/api/resource_handler.mjs +265 -0
- package/package.json +5 -5
- package/dist/api/create_api_handler.d.mts +0 -30
- package/dist/api/create_api_handler.d.ts +0 -30
- package/dist/api/create_api_handler.js +0 -158
- package/dist/api/create_api_handler.mjs +0 -141
- package/dist/api/item_api_handler.d.mts +0 -22
- package/dist/api/item_api_handler.d.ts +0 -22
- package/dist/api/item_api_handler.js +0 -79
- package/dist/api/item_api_handler.mjs +0 -60
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/api/item_api_handler.ts
|
|
21
|
-
var item_api_handler_exports = {};
|
|
22
|
-
__export(item_api_handler_exports, {
|
|
23
|
-
itemApiHandler: () => itemApiHandler
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(item_api_handler_exports);
|
|
26
|
-
var import_gw_response = require("gw-response");
|
|
27
|
-
var import_gw_result = require("gw-result");
|
|
28
|
-
function itemApiHandler({
|
|
29
|
-
withAuthAction,
|
|
30
|
-
repository,
|
|
31
|
-
isOwnedBy,
|
|
32
|
-
roles
|
|
33
|
-
}) {
|
|
34
|
-
const loader = async ({ request }) => {
|
|
35
|
-
return (0, import_gw_result.ok)({});
|
|
36
|
-
};
|
|
37
|
-
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
38
|
-
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
39
|
-
return (0, import_gw_response.httpUnauthorized)({
|
|
40
|
-
code: "UNAUTHORIZED",
|
|
41
|
-
message: "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const itemId = params.itemId;
|
|
45
|
-
const existing = await repository.find(itemId);
|
|
46
|
-
if (!existing) {
|
|
47
|
-
return (0, import_gw_response.httpNotFound)({
|
|
48
|
-
code: "RESOURCE_NOT_FOUND",
|
|
49
|
-
message: "\uC790\uB8CC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (isOwnedBy && !isOwnedBy(existing, auth)) {
|
|
53
|
-
return (0, import_gw_response.httpForbidden)({
|
|
54
|
-
code: "FORBIDDEN",
|
|
55
|
-
message: "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
switch (request.method) {
|
|
59
|
-
case "DELETE": {
|
|
60
|
-
await repository.delete(itemId);
|
|
61
|
-
return (0, import_gw_response.httpNoContent)();
|
|
62
|
-
}
|
|
63
|
-
default: {
|
|
64
|
-
return (0, import_gw_response.httpMethodNotAllowed)({
|
|
65
|
-
code: "METHOD_NOT_ALLOWED",
|
|
66
|
-
message: "\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC740 \uBA54\uC11C\uB4DC\uC785\uB2C8\uB2E4."
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
loader,
|
|
73
|
-
action
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
-
0 && (module.exports = {
|
|
78
|
-
itemApiHandler
|
|
79
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// src/api/item_api_handler.ts
|
|
2
|
-
import {
|
|
3
|
-
httpForbidden,
|
|
4
|
-
httpMethodNotAllowed,
|
|
5
|
-
httpNoContent,
|
|
6
|
-
httpNotFound,
|
|
7
|
-
httpUnauthorized
|
|
8
|
-
} from "gw-response";
|
|
9
|
-
import { ok } from "gw-result";
|
|
10
|
-
function itemApiHandler({
|
|
11
|
-
withAuthAction,
|
|
12
|
-
repository,
|
|
13
|
-
isOwnedBy,
|
|
14
|
-
roles
|
|
15
|
-
}) {
|
|
16
|
-
const loader = async ({ request }) => {
|
|
17
|
-
return ok({});
|
|
18
|
-
};
|
|
19
|
-
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
20
|
-
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
21
|
-
return httpUnauthorized({
|
|
22
|
-
code: "UNAUTHORIZED",
|
|
23
|
-
message: "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const itemId = params.itemId;
|
|
27
|
-
const existing = await repository.find(itemId);
|
|
28
|
-
if (!existing) {
|
|
29
|
-
return httpNotFound({
|
|
30
|
-
code: "RESOURCE_NOT_FOUND",
|
|
31
|
-
message: "\uC790\uB8CC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (isOwnedBy && !isOwnedBy(existing, auth)) {
|
|
35
|
-
return httpForbidden({
|
|
36
|
-
code: "FORBIDDEN",
|
|
37
|
-
message: "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
switch (request.method) {
|
|
41
|
-
case "DELETE": {
|
|
42
|
-
await repository.delete(itemId);
|
|
43
|
-
return httpNoContent();
|
|
44
|
-
}
|
|
45
|
-
default: {
|
|
46
|
-
return httpMethodNotAllowed({
|
|
47
|
-
code: "METHOD_NOT_ALLOWED",
|
|
48
|
-
message: "\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC740 \uBA54\uC11C\uB4DC\uC785\uB2C8\uB2E4."
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
loader,
|
|
55
|
-
action
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
itemApiHandler
|
|
60
|
-
};
|