@modern-js/plugin-koa 1.1.4 → 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 +51 -0
- package/dist/js/modern/cli/index.js +1 -1
- package/dist/js/node/cli/index.js +1 -1
- package/jest.config.js +8 -0
- package/modern.config.js +1 -9
- package/package.json +23 -16
- package/src/cli/index.ts +4 -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 +3 -3
- package/tests/tsconfig.json +1 -3
- package/types.d.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @modern-js/plugin-koa
|
|
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
|
+
|
|
3
54
|
## 1.1.4
|
|
4
55
|
|
|
5
56
|
### 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
|
|
|
@@ -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/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
|
"formidable": "^1.2.2",
|
|
35
40
|
"koa-body": "^4.2.0",
|
|
36
41
|
"koa-router": "^10.0.0",
|
|
@@ -47,12 +52,13 @@
|
|
|
47
52
|
"@types/type-is": "^1.6.3",
|
|
48
53
|
"supertest": "^6.1.6",
|
|
49
54
|
"typescript": "^4",
|
|
50
|
-
"@modern-js/bff-runtime": "^1.
|
|
51
|
-
"@modern-js/bff-utils": "^1.
|
|
52
|
-
"@modern-js/core": "^1.
|
|
53
|
-
"@modern-js/server-plugin": "^1.
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
55
|
+
"@modern-js/bff-runtime": "^1.2.0",
|
|
56
|
+
"@modern-js/bff-utils": "^1.2.0",
|
|
57
|
+
"@modern-js/core": "^1.3.0",
|
|
58
|
+
"@modern-js/server-plugin": "^1.2.0",
|
|
59
|
+
"@scripts/build": "0.0.0",
|
|
60
|
+
"jest": "^27",
|
|
61
|
+
"@scripts/jest-config": "0.0.0"
|
|
56
62
|
},
|
|
57
63
|
"modernConfig": {
|
|
58
64
|
"output": {
|
|
@@ -60,20 +66,21 @@
|
|
|
60
66
|
}
|
|
61
67
|
},
|
|
62
68
|
"peerDependencies": {
|
|
63
|
-
"@modern-js/bff-utils": "^1.
|
|
64
|
-
"@modern-js/core": "^1.
|
|
65
|
-
"@modern-js/server-plugin": "^1.
|
|
66
|
-
"@modern-js/bff-runtime": "^1.
|
|
69
|
+
"@modern-js/bff-utils": "^1.2.0",
|
|
70
|
+
"@modern-js/core": "^1.3.0",
|
|
71
|
+
"@modern-js/server-plugin": "^1.2.0",
|
|
72
|
+
"@modern-js/bff-runtime": "^1.2.0",
|
|
67
73
|
"koa": "^2.13.3"
|
|
68
74
|
},
|
|
69
75
|
"publishConfig": {
|
|
70
76
|
"registry": "https://registry.npmjs.org/",
|
|
71
|
-
"access": "public"
|
|
77
|
+
"access": "public",
|
|
78
|
+
"types": "./dist/types/index.d.ts"
|
|
72
79
|
},
|
|
73
80
|
"scripts": {
|
|
74
81
|
"new": "modern new",
|
|
75
82
|
"build": "modern build",
|
|
76
|
-
"test": "
|
|
83
|
+
"test": "jest --passWithNoTests"
|
|
77
84
|
},
|
|
78
85
|
"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"
|
|
79
86
|
}
|
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/tests/lambdaMode.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import request from 'supertest';
|
|
3
|
-
import Koa
|
|
3
|
+
import Koa from 'koa';
|
|
4
4
|
import { serverManager } from '@modern-js/server-plugin';
|
|
5
5
|
import Router from 'koa-router';
|
|
6
6
|
import koaBody from 'koa-body';
|
|
@@ -111,11 +111,11 @@ describe('add middlewares', () => {
|
|
|
111
111
|
|
|
112
112
|
test('should works', async () => {
|
|
113
113
|
const foo = 'foo';
|
|
114
|
-
const fakeMiddleware = jest.fn(async (ctx:
|
|
114
|
+
const fakeMiddleware = jest.fn(async (ctx: any, next: any) => {
|
|
115
115
|
await next();
|
|
116
116
|
ctx.body = foo;
|
|
117
117
|
});
|
|
118
|
-
const fakeMiddleware2 = jest.fn(async (ctx:
|
|
118
|
+
const fakeMiddleware2 = jest.fn(async (ctx: any, next: any) => {
|
|
119
119
|
await next();
|
|
120
120
|
});
|
|
121
121
|
|
package/tests/tsconfig.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/// <reference path="./dist/types/index.d.ts" />
|
|
2
|
-
|
|
3
2
|
declare module '@modern-js/runtime/server' {
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import { Context, Middleware } from 'koa';
|
|
5
|
+
|
|
6
|
+
type KoaOptions = {
|
|
7
|
+
addMiddleware: (...input: Middleware[]) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type KoaAttacher = (options: KoaOptions) => void;
|
|
5
11
|
|
|
6
12
|
export function useContext(): Context;
|
|
13
|
+
|
|
14
|
+
export function hook(attacher: KoaAttacher): KoaAttacher;
|
|
15
|
+
|
|
16
|
+
export * from '@modern-js/bff-runtime';
|
|
7
17
|
}
|