@modern-js/plugin-express 1.1.5 → 1.3.0
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 +84 -0
- package/dist/js/modern/cli/index.js +1 -1
- package/dist/js/modern/plugin.js +1 -1
- package/dist/js/modern/registerRoutes.js +2 -2
- package/dist/js/node/cli/index.js +1 -1
- package/dist/js/node/plugin.js +1 -1
- package/dist/js/node/registerRoutes.js +2 -2
- package/jest.config.js +8 -0
- package/modern.config.js +1 -9
- package/package.json +26 -18
- package/src/cli/index.ts +4 -1
- package/src/plugin.ts +1 -1
- package/tests/fixtures/function-mode/api/nest/user.ts +1 -1
- package/tests/fixtures/lambda-mode/api/lambda/nest/user.ts +1 -1
- package/tests/lambdaMode.test.ts +2 -2
- package/tests/tsconfig.json +1 -3
- package/tests/webServer.test.ts +1 -1
- package/types.d.ts +12 -1
- package/tests/fixtures/function-mode/api/_app.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @modern-js/plugin-express
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cfe11628: Make Modern.js self bootstraping
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 146dcd85: modify server framework plugin hook types and hook context
|
|
12
|
+
- 146dcd85: modify server framework plugin hook types
|
|
13
|
+
- 146dcd85: fix test case in babel compiler
|
|
14
|
+
- Updated dependencies [2da09c69]
|
|
15
|
+
- Updated dependencies [fc71e36f]
|
|
16
|
+
- Updated dependencies [146dcd85]
|
|
17
|
+
- Updated dependencies [c3d46ee4]
|
|
18
|
+
- Updated dependencies [cfe11628]
|
|
19
|
+
- Updated dependencies [146dcd85]
|
|
20
|
+
- Updated dependencies [8e7603ee]
|
|
21
|
+
- Updated dependencies [146dcd85]
|
|
22
|
+
- @modern-js/utils@1.2.0
|
|
23
|
+
- @modern-js/core@1.3.0
|
|
24
|
+
- @modern-js/bff-runtime@1.2.0
|
|
25
|
+
- @modern-js/adapter-helpers@1.2.0
|
|
26
|
+
- @modern-js/bff-utils@1.2.0
|
|
27
|
+
- @modern-js/server-plugin@1.2.0
|
|
28
|
+
|
|
29
|
+
## 1.2.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- ad107726: feat: new action support apppend type define
|
|
34
|
+
|
|
35
|
+
## 1.2.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 5a4c557e: feat: support bff test
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- a70a62f5: fix: runtime path is broken in development environment
|
|
44
|
+
- Updated dependencies [90eeb72c]
|
|
45
|
+
- Updated dependencies [e04914ce]
|
|
46
|
+
- Updated dependencies [5a4c557e]
|
|
47
|
+
- Updated dependencies [e04914ce]
|
|
48
|
+
- Updated dependencies [ca7dcb32]
|
|
49
|
+
- Updated dependencies [ecb344dc]
|
|
50
|
+
- @modern-js/core@1.2.0
|
|
51
|
+
- @modern-js/server-plugin@1.1.3
|
|
52
|
+
- @modern-js/utils@1.1.5
|
|
53
|
+
|
|
54
|
+
## 1.1.4
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 529d7fae: fix: runtime path is broken in development environment
|
|
59
|
+
- Updated dependencies [d927bc83]
|
|
60
|
+
- Updated dependencies [d73ff455]
|
|
61
|
+
- Updated dependencies [9c1ab865]
|
|
62
|
+
- Updated dependencies [d73ff455]
|
|
63
|
+
- Updated dependencies [d73ff455]
|
|
64
|
+
- Updated dependencies [d73ff455]
|
|
65
|
+
- Updated dependencies [d73ff455]
|
|
66
|
+
- @modern-js/utils@1.1.4
|
|
67
|
+
- @modern-js/core@1.1.4
|
|
68
|
+
|
|
69
|
+
## 1.1.3
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- 39e8137d: fix: support prefix array & webpack loader should read requestCreator & adjust runtime path to relative
|
|
74
|
+
- Updated dependencies [085a6a58]
|
|
75
|
+
- Updated dependencies [085a6a58]
|
|
76
|
+
- Updated dependencies [085a6a58]
|
|
77
|
+
- Updated dependencies [d280ea33]
|
|
78
|
+
- Updated dependencies [d4fcc73a]
|
|
79
|
+
- Updated dependencies [085a6a58]
|
|
80
|
+
- Updated dependencies [ed1f6b12]
|
|
81
|
+
- Updated dependencies [a5ebbb00]
|
|
82
|
+
- Updated dependencies [085a6a58]
|
|
83
|
+
- @modern-js/core@1.1.3
|
|
84
|
+
- @modern-js/server-plugin@1.1.2
|
|
85
|
+
- @modern-js/utils@1.1.3
|
|
86
|
+
|
|
3
87
|
## 1.1.2
|
|
4
88
|
|
|
5
89
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ export default createPlugin(() => {
|
|
|
16
16
|
|
|
17
17
|
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
18
18
|
|
|
19
|
-
if (process.env.NODE_ENV === 'development') {
|
|
19
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
20
20
|
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
21
21
|
}
|
|
22
22
|
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
30
30
|
|
|
31
31
|
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
32
32
|
|
|
33
|
-
if (process.env.NODE_ENV === 'development') {
|
|
33
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
34
34
|
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
35
35
|
}
|
|
36
36
|
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -19,9 +19,9 @@ var _utils = require("@modern-js/utils");
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
23
|
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
|
|
26
26
|
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; }
|
|
27
27
|
|
package/jest.config.js
ADDED
package/modern.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,26 +11,31 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
18
18
|
"module": "./dist/js/treeshaking/index.js",
|
|
19
19
|
"jsnext:modern": "./dist/js/modern/index.js",
|
|
20
20
|
"exports": {
|
|
21
|
+
"./types": "./types.d.ts",
|
|
21
22
|
".": {
|
|
22
23
|
"node": {
|
|
24
|
+
"jsnext:source": "./src/index.ts",
|
|
23
25
|
"import": "./dist/js/modern/index.js",
|
|
24
26
|
"require": "./dist/js/node/index.js"
|
|
25
27
|
},
|
|
26
28
|
"default": "./dist/js/treeshaking/index.js"
|
|
27
29
|
},
|
|
28
|
-
"./cli":
|
|
30
|
+
"./cli": {
|
|
31
|
+
"jsnext:source": "./src/cli/index.ts",
|
|
32
|
+
"default": "./dist/js/node/cli/index.js"
|
|
33
|
+
}
|
|
29
34
|
},
|
|
30
35
|
"dependencies": {
|
|
31
36
|
"@babel/runtime": "^7.15.3",
|
|
32
|
-
"@modern-js/adapter-helpers": "^1.
|
|
33
|
-
"@modern-js/utils": "^1.
|
|
37
|
+
"@modern-js/adapter-helpers": "^1.2.0",
|
|
38
|
+
"@modern-js/utils": "^1.2.0",
|
|
34
39
|
"cookie-parser": "^1.4.5",
|
|
35
40
|
"finalhandler": "^1.1.2",
|
|
36
41
|
"formidable": "^1.2.2",
|
|
@@ -38,8 +43,8 @@
|
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {
|
|
40
45
|
"express": "^4.17.1",
|
|
41
|
-
"@modern-js/server-utils": "^1.
|
|
42
|
-
"@modern-js/bff-runtime": "^1.
|
|
46
|
+
"@modern-js/server-utils": "^1.2.0",
|
|
47
|
+
"@modern-js/bff-runtime": "^1.2.0",
|
|
43
48
|
"@types/cookie-parser": "^1.4.2",
|
|
44
49
|
"@types/express": "^4.17.13",
|
|
45
50
|
"@types/finalhandler": "^1.1.1",
|
|
@@ -50,11 +55,12 @@
|
|
|
50
55
|
"@types/type-is": "^1.6.3",
|
|
51
56
|
"supertest": "^6.1.6",
|
|
52
57
|
"typescript": "^4",
|
|
53
|
-
"@modern-js/bff-utils": "^1.
|
|
54
|
-
"@modern-js/core": "^1.
|
|
55
|
-
"@modern-js/server-plugin": "^1.
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
+
"@modern-js/bff-utils": "^1.2.0",
|
|
59
|
+
"@modern-js/core": "^1.3.0",
|
|
60
|
+
"@modern-js/server-plugin": "^1.2.0",
|
|
61
|
+
"@scripts/build": "0.0.0",
|
|
62
|
+
"jest": "^27",
|
|
63
|
+
"@scripts/jest-config": "0.0.0"
|
|
58
64
|
},
|
|
59
65
|
"modernConfig": {
|
|
60
66
|
"output": {
|
|
@@ -62,19 +68,21 @@
|
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
70
|
"peerDependencies": {
|
|
65
|
-
"@modern-js/bff-utils": "^1.
|
|
66
|
-
"@modern-js/core": "^1.
|
|
67
|
-
"@modern-js/server-plugin": "^1.
|
|
68
|
-
"@modern-js/bff-runtime": "^1.
|
|
71
|
+
"@modern-js/bff-utils": "^1.2.0",
|
|
72
|
+
"@modern-js/core": "^1.3.0",
|
|
73
|
+
"@modern-js/server-plugin": "^1.2.0",
|
|
74
|
+
"@modern-js/bff-runtime": "^1.2.0",
|
|
69
75
|
"express": "^4.17.1"
|
|
70
76
|
},
|
|
71
77
|
"publishConfig": {
|
|
72
78
|
"registry": "https://registry.npmjs.org/",
|
|
73
|
-
"access": "public"
|
|
79
|
+
"access": "public",
|
|
80
|
+
"types": "./dist/types/index.d.ts"
|
|
74
81
|
},
|
|
75
82
|
"scripts": {
|
|
76
83
|
"new": "modern new",
|
|
77
84
|
"build": "modern build",
|
|
78
|
-
"test": "
|
|
79
|
-
}
|
|
85
|
+
"test": "jest --passWithNoTests"
|
|
86
|
+
},
|
|
87
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
80
88
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -25,7 +25,10 @@ export default createPlugin(
|
|
|
25
25
|
path.relative(appDirectory, serverRuntimePath),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (
|
|
29
|
+
process.env.NODE_ENV === 'development' ||
|
|
30
|
+
process.env.NODE_ENV === 'test'
|
|
31
|
+
) {
|
|
29
32
|
relativeRuntimePath = `./${path.relative(
|
|
30
33
|
appDirectory,
|
|
31
34
|
serverRuntimePath,
|
package/src/plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
2
2
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
3
3
|
import { match } from '@modern-js/bff-runtime';
|
|
4
|
-
import { useContext } from '
|
|
4
|
+
import { useContext } from '../../../../../src/context';
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line arrow-body-style
|
|
7
7
|
export const get = ({ query }: { query: Record<string, unknown> }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
2
2
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
3
3
|
import { match } from '@modern-js/bff-runtime';
|
|
4
|
-
import { useContext } from '
|
|
4
|
+
import { useContext } from '../../../../../../src/context';
|
|
5
5
|
|
|
6
6
|
export const get = ({ query }: { query: Record<string, unknown> }) => ({
|
|
7
7
|
query,
|
package/tests/lambdaMode.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import express
|
|
2
|
+
import express from 'express';
|
|
3
3
|
import request from 'supertest';
|
|
4
4
|
import { serverManager } from '@modern-js/server-plugin';
|
|
5
5
|
import { INTROSPECTION_ROUTE_PATH } from '@modern-js/bff-utils';
|
|
@@ -333,7 +333,7 @@ describe('support as async handler', () => {
|
|
|
333
333
|
config: { middleware: [wrapMiddleware] },
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
const asyncHandler = async (req:
|
|
336
|
+
const asyncHandler = async (req: any, res: any) => {
|
|
337
337
|
await apiHandler(req, res);
|
|
338
338
|
order.push(3);
|
|
339
339
|
};
|
package/tests/tsconfig.json
CHANGED
package/tests/webServer.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Buffer } from 'buffer';
|
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
4
|
import request from 'supertest';
|
|
5
5
|
import { serverManager } from '@modern-js/server-plugin';
|
|
6
|
-
import plugin from '
|
|
6
|
+
import plugin from '../src/plugin';
|
|
7
7
|
import './common';
|
|
8
8
|
|
|
9
9
|
const pwd = path.join(__dirname, './fixtures/function-mode');
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/// <reference path="./dist/types/index.d.ts" />
|
|
2
2
|
|
|
3
3
|
declare module '@modern-js/runtime/server' {
|
|
4
|
-
import { Request, Response } from 'express';
|
|
4
|
+
import { Request, Response, RequestHandler } from 'express';
|
|
5
|
+
|
|
6
|
+
type ExpressOptions = {
|
|
7
|
+
addMiddleware: (...input: RequestHandler[]) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type ExpressAttacher = (options: ExpressOptions) => void;
|
|
5
11
|
|
|
6
12
|
type Context = { req: Request; res: Response };
|
|
13
|
+
|
|
7
14
|
export function useContext(): Context;
|
|
15
|
+
|
|
16
|
+
export function hook(attacher: ExpressAttacher): ExpressAttacher;
|
|
17
|
+
|
|
18
|
+
export * from '@modern-js/bff-runtime';
|
|
8
19
|
}
|