@modern-js/bff-core 2.0.0-beta.3 → 2.0.0-beta.6
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/CHANGELOG.md +75 -0
- package/dist/js/modern/api.js +49 -25
- package/dist/js/modern/client/generate-client.js +51 -24
- package/dist/js/modern/client/index.js +1 -1
- package/dist/js/modern/client/result.js +9 -8
- package/dist/js/modern/errors/http.js +8 -7
- package/dist/js/modern/index.js +19 -3
- package/dist/js/modern/operators/http.js +139 -87
- package/dist/js/modern/router/constants.js +31 -11
- package/dist/js/modern/router/index.js +66 -69
- package/dist/js/modern/router/types.js +0 -1
- package/dist/js/modern/router/utils.js +36 -37
- package/dist/js/modern/types.js +45 -37
- package/dist/js/modern/utils/alias.js +32 -30
- package/dist/js/modern/utils/debug.js +5 -2
- package/dist/js/modern/utils/index.js +5 -2
- package/dist/js/modern/utils/meta.js +8 -4
- package/dist/js/modern/utils/storage.js +8 -4
- package/dist/js/modern/utils/validate.js +22 -23
- package/dist/js/node/api.js +78 -32
- package/dist/js/node/client/generate-client.js +84 -37
- package/dist/js/node/client/index.js +17 -16
- package/dist/js/node/client/result.js +31 -14
- package/dist/js/node/errors/http.js +28 -11
- package/dist/js/node/index.js +45 -111
- package/dist/js/node/operators/http.js +184 -124
- package/dist/js/node/router/constants.js +60 -24
- package/dist/js/node/router/index.js +110 -125
- package/dist/js/node/router/types.js +15 -5
- package/dist/js/node/router/utils.js +71 -51
- package/dist/js/node/types.js +71 -47
- package/dist/js/node/utils/alias.js +63 -42
- package/dist/js/node/utils/debug.js +27 -8
- package/dist/js/node/utils/index.js +28 -59
- package/dist/js/node/utils/meta.js +30 -10
- package/dist/js/node/utils/storage.js +36 -11
- package/dist/js/node/utils/validate.js +49 -28
- package/dist/types/router/constants.d.ts +1 -0
- package/dist/types/router/index.d.ts +1 -0
- package/package.json +5 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as ah from
|
|
1
|
+
import * as ah from "async_hooks";
|
|
2
2
|
const createStorage = () => {
|
|
3
3
|
let storage;
|
|
4
|
-
if (typeof ah.AsyncLocalStorage !==
|
|
4
|
+
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
|
5
5
|
storage = new ah.AsyncLocalStorage();
|
|
6
6
|
}
|
|
7
7
|
const run = (context, cb) => {
|
|
@@ -26,7 +26,9 @@ const createStorage = () => {
|
|
|
26
26
|
}
|
|
27
27
|
const context = storage.getStore();
|
|
28
28
|
if (!context) {
|
|
29
|
-
throw new Error(
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Can't call useContext out of scope, it should be placed in the bff function`
|
|
31
|
+
);
|
|
30
32
|
}
|
|
31
33
|
return context;
|
|
32
34
|
};
|
|
@@ -35,4 +37,6 @@ const createStorage = () => {
|
|
|
35
37
|
useContext
|
|
36
38
|
};
|
|
37
39
|
};
|
|
38
|
-
export {
|
|
40
|
+
export {
|
|
41
|
+
createStorage
|
|
42
|
+
};
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import util from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let msg = '';
|
|
1
|
+
import util from "util";
|
|
2
|
+
const getTypeErrorMessage = (actual) => {
|
|
3
|
+
var _a;
|
|
4
|
+
let msg = "";
|
|
6
5
|
if (actual == null) {
|
|
7
6
|
msg += `. Received ${actual}`;
|
|
8
|
-
} else if (typeof actual ===
|
|
7
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
9
8
|
msg += `. Received function ${actual.name}`;
|
|
10
|
-
} else if (typeof actual ===
|
|
11
|
-
|
|
12
|
-
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
9
|
+
} else if (typeof actual === "object") {
|
|
10
|
+
if ((_a = actual.constructor) == null ? void 0 : _a.name) {
|
|
13
11
|
msg += `. Received an instance of ${actual.constructor.name}`;
|
|
14
12
|
} else {
|
|
15
|
-
const inspected = util.inspect(actual, {
|
|
16
|
-
depth: -1
|
|
17
|
-
});
|
|
13
|
+
const inspected = util.inspect(actual, { depth: -1 });
|
|
18
14
|
msg += `. Received ${inspected}`;
|
|
19
15
|
}
|
|
20
16
|
} else {
|
|
21
|
-
let inspected = util.inspect(actual, {
|
|
22
|
-
colors: false
|
|
23
|
-
});
|
|
17
|
+
let inspected = util.inspect(actual, { colors: false });
|
|
24
18
|
if (inspected.length > 25) {
|
|
25
19
|
inspected = `${inspected.slice(0, 25)}...`;
|
|
26
20
|
}
|
|
@@ -28,17 +22,22 @@ export const getTypeErrorMessage = actual => {
|
|
|
28
22
|
}
|
|
29
23
|
return msg;
|
|
30
24
|
};
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
|
-
export class ERR_INVALID_ARG_TYPE extends Error {
|
|
25
|
+
class ERR_INVALID_ARG_TYPE extends Error {
|
|
34
26
|
constructor(funcName, expectedType, actual) {
|
|
35
|
-
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
27
|
+
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
28
|
+
actual
|
|
29
|
+
)}`;
|
|
36
30
|
super(message);
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
if (typeof maybeFunc !==
|
|
41
|
-
throw new ERR_INVALID_ARG_TYPE(name,
|
|
33
|
+
const validateFunction = (maybeFunc, name) => {
|
|
34
|
+
if (typeof maybeFunc !== "function") {
|
|
35
|
+
throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
|
|
42
36
|
}
|
|
43
37
|
return true;
|
|
44
|
-
};
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
ERR_INVALID_ARG_TYPE,
|
|
41
|
+
getTypeErrorMessage,
|
|
42
|
+
validateFunction
|
|
43
|
+
};
|
package/dist/js/node/api.js
CHANGED
|
@@ -1,16 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var api_exports = {};
|
|
45
|
+
__export(api_exports, {
|
|
46
|
+
Api: () => Api
|
|
5
47
|
});
|
|
6
|
-
exports
|
|
7
|
-
require("reflect-metadata");
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
|
+
module.exports = __toCommonJS(api_exports);
|
|
49
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
50
|
+
var import_koa_compose = __toESM(require("koa-compose"));
|
|
51
|
+
var import_utils = require("./utils");
|
|
11
52
|
function Api(...args) {
|
|
12
53
|
const handler = args.pop();
|
|
13
|
-
(0,
|
|
54
|
+
(0, import_utils.validateFunction)(handler, "Apihandler");
|
|
14
55
|
const operators = args;
|
|
15
56
|
const metadataHelper = {
|
|
16
57
|
getMetadata(key) {
|
|
@@ -25,28 +66,33 @@ function Api(...args) {
|
|
|
25
66
|
operator.metadata(metadataHelper);
|
|
26
67
|
}
|
|
27
68
|
}
|
|
28
|
-
const validateHandlers = operators.filter(operator => operator.validate).map(operator => operator.validate);
|
|
29
|
-
const pipeHandlers = operators.filter(operator => operator.execute).map(operator => operator.execute);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
69
|
+
const validateHandlers = operators.filter((operator) => operator.validate).map((operator) => operator.validate);
|
|
70
|
+
const pipeHandlers = operators.filter((operator) => operator.execute).map((operator) => operator.execute);
|
|
71
|
+
function runner(inputs) {
|
|
72
|
+
return __async(this, null, function* () {
|
|
73
|
+
const executeHelper = {
|
|
74
|
+
result: null,
|
|
75
|
+
get inputs() {
|
|
76
|
+
return inputs;
|
|
77
|
+
},
|
|
78
|
+
set inputs(val) {
|
|
79
|
+
inputs = val;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const stack = [...validateHandlers, ...pipeHandlers];
|
|
83
|
+
stack.push((helper, next) => __async(this, null, function* () {
|
|
84
|
+
const res = yield handler(helper.inputs);
|
|
85
|
+
helper.result = res;
|
|
86
|
+
return next();
|
|
87
|
+
}));
|
|
88
|
+
yield (0, import_koa_compose.default)(stack)(executeHelper);
|
|
89
|
+
return executeHelper.result;
|
|
46
90
|
});
|
|
47
|
-
await (0, _koaCompose.default)(stack)(executeHelper);
|
|
48
|
-
return executeHelper.result;
|
|
49
91
|
}
|
|
50
|
-
runner[
|
|
92
|
+
runner[import_utils.HANDLER_WITH_META] = true;
|
|
51
93
|
return runner;
|
|
52
|
-
}
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
Api
|
|
98
|
+
});
|
|
@@ -1,17 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var generate_client_exports = {};
|
|
45
|
+
__export(generate_client_exports, {
|
|
46
|
+
DEFAULT_CLIENT_REQUEST_CREATOR: () => DEFAULT_CLIENT_REQUEST_CREATOR,
|
|
47
|
+
generateClient: () => generateClient
|
|
5
48
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const DEFAULT_CLIENT_REQUEST_CREATOR = '@modern-js/create-request';
|
|
13
|
-
exports.DEFAULT_CLIENT_REQUEST_CREATOR = DEFAULT_CLIENT_REQUEST_CREATOR;
|
|
14
|
-
const generateClient = async ({
|
|
49
|
+
module.exports = __toCommonJS(generate_client_exports);
|
|
50
|
+
var path = __toESM(require("path"));
|
|
51
|
+
var import_router = require("../router");
|
|
52
|
+
var import_result = require("./result");
|
|
53
|
+
const DEFAULT_CLIENT_REQUEST_CREATOR = "@modern-js/create-request";
|
|
54
|
+
const generateClient = (_0) => __async(void 0, [_0], function* ({
|
|
15
55
|
resourcePath,
|
|
16
56
|
apiDir,
|
|
17
57
|
prefix,
|
|
@@ -19,46 +59,53 @@ const generateClient = async ({
|
|
|
19
59
|
target,
|
|
20
60
|
requestCreator,
|
|
21
61
|
fetcher,
|
|
22
|
-
requireResolve
|
|
23
|
-
})
|
|
62
|
+
requireResolve = require.resolve
|
|
63
|
+
}) {
|
|
24
64
|
if (!requestCreator) {
|
|
25
|
-
|
|
26
|
-
|
|
65
|
+
requestCreator = requireResolve(
|
|
66
|
+
`${DEFAULT_CLIENT_REQUEST_CREATOR}${target ? `/${target}` : ""}`
|
|
67
|
+
).replace(/\\/g, "/");
|
|
27
68
|
} else {
|
|
28
|
-
// 这里约束传入的 requestCreator 包也必须有两个导出 client 和 server,因为目前的机制 client 和 server 要导出不同的 configure 函数;该 api 不对使用者暴露,后续可优化
|
|
29
69
|
let resolvedPath = requestCreator;
|
|
30
70
|
try {
|
|
31
|
-
resolvedPath = path.dirname(
|
|
32
|
-
} catch (error) {
|
|
33
|
-
|
|
34
|
-
requestCreator = `${resolvedPath}${target ? `/${target}` :
|
|
71
|
+
resolvedPath = path.dirname(requireResolve(requestCreator));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
}
|
|
74
|
+
requestCreator = `${resolvedPath}${target ? `/${target}` : ""}`.replace(
|
|
75
|
+
/\\/g,
|
|
76
|
+
"/"
|
|
77
|
+
);
|
|
35
78
|
}
|
|
36
|
-
const apiRouter = new
|
|
79
|
+
const apiRouter = new import_router.ApiRouter({
|
|
37
80
|
apiDir,
|
|
38
81
|
prefix
|
|
39
82
|
});
|
|
40
83
|
const handlerInfos = apiRouter.getSingleModuleHandlers(resourcePath);
|
|
41
84
|
if (!handlerInfos) {
|
|
42
|
-
return (0,
|
|
85
|
+
return (0, import_result.Err)(`generate client error: Cannot require module ${resourcePath}`);
|
|
43
86
|
}
|
|
44
|
-
let handlersCode =
|
|
87
|
+
let handlersCode = "";
|
|
45
88
|
for (const handlerInfo of handlerInfos) {
|
|
46
|
-
const {
|
|
47
|
-
name,
|
|
48
|
-
httpMethod,
|
|
49
|
-
routePath
|
|
50
|
-
} = handlerInfo;
|
|
89
|
+
const { name, httpMethod, routePath } = handlerInfo;
|
|
51
90
|
let exportStatement = `const ${name} =`;
|
|
52
|
-
if (name.toLowerCase() ===
|
|
53
|
-
exportStatement =
|
|
91
|
+
if (name.toLowerCase() === "default") {
|
|
92
|
+
exportStatement = "default";
|
|
54
93
|
}
|
|
55
94
|
const upperHttpMethod = httpMethod.toUpperCase();
|
|
56
95
|
const routeName = routePath;
|
|
57
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${String(
|
|
96
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${String(
|
|
97
|
+
port
|
|
98
|
+
)}${fetcher ? `, fetch` : ""});
|
|
58
99
|
`;
|
|
59
100
|
}
|
|
60
101
|
const importCode = `import { createRequest } from '${requestCreator}';
|
|
61
|
-
${fetcher ? `import { fetch } from '${fetcher}'
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
102
|
+
${fetcher ? `import { fetch } from '${fetcher}';
|
|
103
|
+
` : ""}`;
|
|
104
|
+
return (0, import_result.Ok)(`${importCode}
|
|
105
|
+
${handlersCode}`);
|
|
106
|
+
});
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
DEFAULT_CLIENT_REQUEST_CREATOR,
|
|
110
|
+
generateClient
|
|
111
|
+
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var client_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(client_exports);
|
|
17
|
+
__reExport(client_exports, require("./generate-client"), module.exports);
|
|
@@ -1,29 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var result_exports = {};
|
|
19
|
+
__export(result_exports, {
|
|
20
|
+
Err: () => Err,
|
|
21
|
+
Ok: () => Ok
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const Err = value => {
|
|
23
|
+
module.exports = __toCommonJS(result_exports);
|
|
24
|
+
const Err = (value) => {
|
|
9
25
|
const err = {
|
|
10
|
-
kind:
|
|
26
|
+
kind: "Err",
|
|
11
27
|
value,
|
|
12
28
|
isErr: true,
|
|
13
29
|
isOk: false
|
|
14
30
|
};
|
|
15
31
|
return err;
|
|
16
32
|
};
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
19
|
-
exports.Err = Err;
|
|
20
|
-
const Ok = value => {
|
|
33
|
+
const Ok = (value) => {
|
|
21
34
|
const ok = {
|
|
22
|
-
kind:
|
|
35
|
+
kind: "Ok",
|
|
23
36
|
value,
|
|
24
37
|
isErr: false,
|
|
25
38
|
isOk: true
|
|
26
39
|
};
|
|
27
40
|
return ok;
|
|
28
41
|
};
|
|
29
|
-
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
Err,
|
|
45
|
+
Ok
|
|
46
|
+
});
|
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var http_exports = {};
|
|
19
|
+
__export(http_exports, {
|
|
20
|
+
HttpError: () => HttpError,
|
|
21
|
+
ValidationError: () => ValidationError
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
+
module.exports = __toCommonJS(http_exports);
|
|
8
24
|
class HttpError extends Error {
|
|
9
25
|
constructor(status, message) {
|
|
10
26
|
super(message);
|
|
11
|
-
_defineProperty(this, "status", void 0);
|
|
12
27
|
this.status = status;
|
|
13
28
|
}
|
|
14
29
|
}
|
|
15
|
-
exports.HttpError = HttpError;
|
|
16
30
|
class ValidationError extends HttpError {
|
|
17
31
|
constructor(status, message) {
|
|
18
32
|
super(status, message);
|
|
19
|
-
|
|
20
|
-
this.code = 'VALIDATION_ERROR';
|
|
33
|
+
this.code = "VALIDATION_ERROR";
|
|
21
34
|
}
|
|
22
35
|
}
|
|
23
|
-
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
HttpError,
|
|
39
|
+
ValidationError
|
|
40
|
+
});
|