@modern-js/bff-core 2.48.0 → 2.48.1
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/cjs/errors/http.js
CHANGED
|
@@ -22,18 +22,15 @@ __export(http_exports, {
|
|
|
22
22
|
ValidationError: () => ValidationError
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(http_exports);
|
|
25
|
-
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
26
25
|
class HttpError extends Error {
|
|
27
26
|
constructor(status, message) {
|
|
28
27
|
super(message);
|
|
29
|
-
(0, import_define_property._)(this, "status", void 0);
|
|
30
28
|
this.status = status;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
class ValidationError extends HttpError {
|
|
34
32
|
constructor(status, message) {
|
|
35
33
|
super(status, message);
|
|
36
|
-
(0, import_define_property._)(this, "code", void 0);
|
|
37
34
|
this.code = "VALIDATION_ERROR";
|
|
38
35
|
}
|
|
39
36
|
}
|
package/dist/cjs/router/index.js
CHANGED
|
@@ -32,7 +32,6 @@ __export(router_exports, {
|
|
|
32
32
|
ApiRouter: () => ApiRouter
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(router_exports);
|
|
35
|
-
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
36
35
|
var import_path = __toESM(require("path"));
|
|
37
36
|
var import_utils = require("@modern-js/utils");
|
|
38
37
|
var import_reflect_metadata = require("reflect-metadata");
|
|
@@ -277,16 +276,8 @@ class ApiRouter {
|
|
|
277
276
|
return `${prefix}${finalRouteName}`;
|
|
278
277
|
}
|
|
279
278
|
constructor({ appDir, apiDir, lambdaDir, prefix, isBuild, httpMethodDecider = "functionName" }) {
|
|
280
|
-
|
|
281
|
-
(
|
|
282
|
-
(0, import_define_property._)(this, "apiDir", void 0);
|
|
283
|
-
(0, import_define_property._)(this, "existLambdaDir", void 0);
|
|
284
|
-
(0, import_define_property._)(this, "httpMethodDecider", void 0);
|
|
285
|
-
(0, import_define_property._)(this, "lambdaDir", void 0);
|
|
286
|
-
(0, import_define_property._)(this, "prefix", void 0);
|
|
287
|
-
(0, import_define_property._)(this, "apiFiles", []);
|
|
288
|
-
(0, import_define_property._)(this, "isBuild", void 0);
|
|
289
|
-
(0, import_define_property._)(this, "getExactApiMode", (apiDir2, lambdaDir2) => {
|
|
279
|
+
this.apiFiles = [];
|
|
280
|
+
this.getExactApiMode = (apiDir2, lambdaDir2) => {
|
|
290
281
|
const exist = this.createExistChecker(apiDir2);
|
|
291
282
|
const existLambdaDir = lambdaDir2 && import_utils.fs.pathExistsSync(lambdaDir2) || exist(import_constants.FRAMEWORK_MODE_LAMBDA_DIR);
|
|
292
283
|
const existAppDir = exist(import_constants.FRAMEWORK_MODE_APP_DIR);
|
|
@@ -295,14 +286,14 @@ class ApiRouter {
|
|
|
295
286
|
return import_constants.APIMode.FARMEWORK;
|
|
296
287
|
}
|
|
297
288
|
return import_constants.APIMode.FUNCTION;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
289
|
+
};
|
|
290
|
+
this.createExistChecker = (base) => (target) => import_utils.fs.pathExistsSync(import_path.default.resolve(base, target));
|
|
291
|
+
this.getExactLambdaDir = (apiDir2, originLambdaDir) => {
|
|
301
292
|
if (this.apiMode === import_constants.APIMode.FUNCTION) {
|
|
302
293
|
return apiDir2;
|
|
303
294
|
}
|
|
304
295
|
return originLambdaDir || import_path.default.join(apiDir2, import_constants.FRAMEWORK_MODE_LAMBDA_DIR);
|
|
305
|
-
}
|
|
296
|
+
};
|
|
306
297
|
this.validateAbsolute(apiDir, "apiDir");
|
|
307
298
|
this.validateAbsolute(lambdaDir, "lambdaDir");
|
|
308
299
|
this.prefix = this.initPrefix(prefix);
|
package/dist/esm/errors/http.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
1
|
class HttpError extends Error {
|
|
3
2
|
constructor(status, message) {
|
|
4
3
|
super(message);
|
|
5
|
-
_define_property(this, "status", void 0);
|
|
6
4
|
this.status = status;
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
7
|
class ValidationError extends HttpError {
|
|
10
8
|
constructor(status, message) {
|
|
11
9
|
super(status, message);
|
|
12
|
-
_define_property(this, "code", void 0);
|
|
13
10
|
this.code = "VALIDATION_ERROR";
|
|
14
11
|
}
|
|
15
12
|
}
|
package/dist/esm/router/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { fs, logger } from "@modern-js/utils";
|
|
4
3
|
import "reflect-metadata";
|
|
@@ -243,16 +242,8 @@ class ApiRouter {
|
|
|
243
242
|
return `${prefix}${finalRouteName}`;
|
|
244
243
|
}
|
|
245
244
|
constructor({ appDir, apiDir, lambdaDir, prefix, isBuild, httpMethodDecider = "functionName" }) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
_define_property(this, "apiDir", void 0);
|
|
249
|
-
_define_property(this, "existLambdaDir", void 0);
|
|
250
|
-
_define_property(this, "httpMethodDecider", void 0);
|
|
251
|
-
_define_property(this, "lambdaDir", void 0);
|
|
252
|
-
_define_property(this, "prefix", void 0);
|
|
253
|
-
_define_property(this, "apiFiles", []);
|
|
254
|
-
_define_property(this, "isBuild", void 0);
|
|
255
|
-
_define_property(this, "getExactApiMode", (apiDir2, lambdaDir2) => {
|
|
245
|
+
this.apiFiles = [];
|
|
246
|
+
this.getExactApiMode = (apiDir2, lambdaDir2) => {
|
|
256
247
|
const exist = this.createExistChecker(apiDir2);
|
|
257
248
|
const existLambdaDir = lambdaDir2 && fs.pathExistsSync(lambdaDir2) || exist(FRAMEWORK_MODE_LAMBDA_DIR);
|
|
258
249
|
const existAppDir = exist(FRAMEWORK_MODE_APP_DIR);
|
|
@@ -261,14 +252,14 @@ class ApiRouter {
|
|
|
261
252
|
return APIMode.FARMEWORK;
|
|
262
253
|
}
|
|
263
254
|
return APIMode.FUNCTION;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
255
|
+
};
|
|
256
|
+
this.createExistChecker = (base) => (target) => fs.pathExistsSync(path.resolve(base, target));
|
|
257
|
+
this.getExactLambdaDir = (apiDir2, originLambdaDir) => {
|
|
267
258
|
if (this.apiMode === APIMode.FUNCTION) {
|
|
268
259
|
return apiDir2;
|
|
269
260
|
}
|
|
270
261
|
return originLambdaDir || path.join(apiDir2, FRAMEWORK_MODE_LAMBDA_DIR);
|
|
271
|
-
}
|
|
262
|
+
};
|
|
272
263
|
this.validateAbsolute(apiDir, "apiDir");
|
|
273
264
|
this.validateAbsolute(lambdaDir, "lambdaDir");
|
|
274
265
|
this.prefix = this.initPrefix(prefix);
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.48.
|
|
18
|
+
"version": "2.48.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"koa-compose": "^4.1.0",
|
|
32
32
|
"reflect-metadata": "^0.1.13",
|
|
33
|
+
"type-fest": "2.15.0",
|
|
33
34
|
"@swc/helpers": "0.5.3",
|
|
34
|
-
"@modern-js/utils": "2.48.
|
|
35
|
+
"@modern-js/utils": "2.48.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/jest": "^29",
|
|
@@ -40,12 +41,11 @@
|
|
|
40
41
|
"jest": "^29",
|
|
41
42
|
"ts-node": "^10.9.1",
|
|
42
43
|
"tsconfig-paths": "^4.1.2",
|
|
43
|
-
"type-fest": "2.15.0",
|
|
44
44
|
"typescript": "^5",
|
|
45
45
|
"zod": "^3.22.3",
|
|
46
|
-
"@modern-js/types": "2.48.
|
|
47
|
-
"@scripts/
|
|
48
|
-
"@scripts/
|
|
46
|
+
"@modern-js/types": "2.48.1",
|
|
47
|
+
"@scripts/jest-config": "2.48.1",
|
|
48
|
+
"@scripts/build": "2.48.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.22.3",
|