@modern-js/plugin-koa 2.53.0 → 2.54.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/cli/index.js +2 -2
- package/dist/cjs/plugin.js +15 -14
- package/dist/esm/cli/index.js +2 -2
- package/dist/esm/plugin.js +12 -5
- package/dist/esm-node/cli/index.js +2 -2
- package/dist/esm-node/plugin.js +15 -14
- package/dist/types/plugin.d.ts +5 -4
- package/package.json +10 -10
package/dist/cjs/cli/index.js
CHANGED
|
@@ -60,9 +60,9 @@ const koaPlugin = () => ({
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
_internalServerPlugins({ plugins }) {
|
|
64
64
|
plugins.push({
|
|
65
|
-
|
|
65
|
+
name: "@modern-js/plugin-koa/server"
|
|
66
66
|
});
|
|
67
67
|
return {
|
|
68
68
|
plugins
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -36,7 +36,7 @@ var import_koa = __toESM(require("koa"));
|
|
|
36
36
|
var import_koa_router = __toESM(require("koa-router"));
|
|
37
37
|
var import_koa_body = __toESM(require("koa-body"));
|
|
38
38
|
var import_utils = require("@modern-js/utils");
|
|
39
|
-
var import_node = require("@modern-js/server-core/
|
|
39
|
+
var import_node = require("@modern-js/server-core/node");
|
|
40
40
|
var import_context = require("./context");
|
|
41
41
|
var import_registerRoutes = __toESM(require("./registerRoutes"));
|
|
42
42
|
const findAppModule = async (apiDir) => {
|
|
@@ -105,7 +105,7 @@ const createApp = async ({ apiDir, middlewares, mode, apiHandlerInfos, render })
|
|
|
105
105
|
app.use(router.routes());
|
|
106
106
|
if (render) {
|
|
107
107
|
app.use(async (ctx, next) => {
|
|
108
|
-
const response = await render(ctx.req.__honoRequest, {
|
|
108
|
+
const response = await render(ctx.req.__honoRequest.raw, {
|
|
109
109
|
logger: import_utils.logger,
|
|
110
110
|
nodeReq: ctx.req,
|
|
111
111
|
templates: ctx.req.__templates,
|
|
@@ -133,18 +133,19 @@ var plugin_default = () => {
|
|
|
133
133
|
"@modern-js/plugin-server"
|
|
134
134
|
],
|
|
135
135
|
setup: (api) => ({
|
|
136
|
-
async
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
async reset({ event }) {
|
|
137
|
+
if (event.type === "file-change") {
|
|
138
|
+
const appContext = api.useAppContext();
|
|
139
|
+
const middlewares = appContext.apiMiddlewares;
|
|
140
|
+
const apiHandlerInfos = appContext.apiHandlerInfos;
|
|
141
|
+
app = await createApp({
|
|
142
|
+
apiDir,
|
|
143
|
+
middlewares,
|
|
144
|
+
mode,
|
|
145
|
+
apiHandlerInfos,
|
|
146
|
+
render: renderHtml
|
|
147
|
+
});
|
|
148
|
+
}
|
|
148
149
|
},
|
|
149
150
|
async prepareApiServer({ pwd, render }) {
|
|
150
151
|
var _userConfig_bff;
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -27,10 +27,10 @@ var koaPlugin = function() {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
_internalServerPlugins: function _internalServerPlugins(param) {
|
|
31
31
|
var plugins = param.plugins;
|
|
32
32
|
plugins.push({
|
|
33
|
-
|
|
33
|
+
name: "@modern-js/plugin-koa/server"
|
|
34
34
|
});
|
|
35
35
|
return {
|
|
36
36
|
plugins
|
package/dist/esm/plugin.js
CHANGED
|
@@ -6,7 +6,7 @@ import Koa from "koa";
|
|
|
6
6
|
import Router from "koa-router";
|
|
7
7
|
import koaBody from "koa-body";
|
|
8
8
|
import { fs, compatRequire, logger } from "@modern-js/utils";
|
|
9
|
-
import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/
|
|
9
|
+
import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/node";
|
|
10
10
|
import { run } from "./context";
|
|
11
11
|
import registerRoutes from "./registerRoutes";
|
|
12
12
|
var findAppModule = function() {
|
|
@@ -195,7 +195,7 @@ var createApp = function() {
|
|
|
195
195
|
case 0:
|
|
196
196
|
return [
|
|
197
197
|
4,
|
|
198
|
-
render(ctx.req.__honoRequest, {
|
|
198
|
+
render(ctx.req.__honoRequest.raw, {
|
|
199
199
|
logger,
|
|
200
200
|
nodeReq: ctx.req,
|
|
201
201
|
templates: ctx.req.__templates,
|
|
@@ -260,12 +260,18 @@ function plugin_default() {
|
|
|
260
260
|
],
|
|
261
261
|
setup: function(api) {
|
|
262
262
|
return {
|
|
263
|
-
|
|
263
|
+
reset: function reset(param) {
|
|
264
|
+
var event = param.event;
|
|
264
265
|
return _async_to_generator(function() {
|
|
265
266
|
var appContext, middlewares, apiHandlerInfos;
|
|
266
267
|
return _ts_generator(this, function(_state) {
|
|
267
268
|
switch (_state.label) {
|
|
268
269
|
case 0:
|
|
270
|
+
if (!(event.type === "file-change"))
|
|
271
|
+
return [
|
|
272
|
+
3,
|
|
273
|
+
2
|
|
274
|
+
];
|
|
269
275
|
appContext = api.useAppContext();
|
|
270
276
|
middlewares = appContext.apiMiddlewares;
|
|
271
277
|
apiHandlerInfos = appContext.apiHandlerInfos;
|
|
@@ -281,9 +287,10 @@ function plugin_default() {
|
|
|
281
287
|
];
|
|
282
288
|
case 1:
|
|
283
289
|
app = _state.sent();
|
|
290
|
+
_state.label = 2;
|
|
291
|
+
case 2:
|
|
284
292
|
return [
|
|
285
|
-
2
|
|
286
|
-
changes
|
|
293
|
+
2
|
|
287
294
|
];
|
|
288
295
|
}
|
|
289
296
|
});
|
|
@@ -26,9 +26,9 @@ const koaPlugin = () => ({
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
_internalServerPlugins({ plugins }) {
|
|
30
30
|
plugins.push({
|
|
31
|
-
|
|
31
|
+
name: "@modern-js/plugin-koa/server"
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
34
34
|
plugins
|
package/dist/esm-node/plugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import Koa from "koa";
|
|
|
3
3
|
import Router from "koa-router";
|
|
4
4
|
import koaBody from "koa-body";
|
|
5
5
|
import { fs, compatRequire, logger } from "@modern-js/utils";
|
|
6
|
-
import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/
|
|
6
|
+
import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/node";
|
|
7
7
|
import { run } from "./context";
|
|
8
8
|
import registerRoutes from "./registerRoutes";
|
|
9
9
|
const findAppModule = async (apiDir) => {
|
|
@@ -72,7 +72,7 @@ const createApp = async ({ apiDir, middlewares, mode, apiHandlerInfos, render })
|
|
|
72
72
|
app.use(router.routes());
|
|
73
73
|
if (render) {
|
|
74
74
|
app.use(async (ctx, next) => {
|
|
75
|
-
const response = await render(ctx.req.__honoRequest, {
|
|
75
|
+
const response = await render(ctx.req.__honoRequest.raw, {
|
|
76
76
|
logger,
|
|
77
77
|
nodeReq: ctx.req,
|
|
78
78
|
templates: ctx.req.__templates,
|
|
@@ -100,18 +100,19 @@ var plugin_default = () => {
|
|
|
100
100
|
"@modern-js/plugin-server"
|
|
101
101
|
],
|
|
102
102
|
setup: (api) => ({
|
|
103
|
-
async
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
async reset({ event }) {
|
|
104
|
+
if (event.type === "file-change") {
|
|
105
|
+
const appContext = api.useAppContext();
|
|
106
|
+
const middlewares = appContext.apiMiddlewares;
|
|
107
|
+
const apiHandlerInfos = appContext.apiHandlerInfos;
|
|
108
|
+
app = await createApp({
|
|
109
|
+
apiDir,
|
|
110
|
+
middlewares,
|
|
111
|
+
mode,
|
|
112
|
+
apiHandlerInfos,
|
|
113
|
+
render: renderHtml
|
|
114
|
+
});
|
|
115
|
+
}
|
|
115
116
|
},
|
|
116
117
|
async prepareApiServer({ pwd, render }) {
|
|
117
118
|
var _userConfig_bff;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ServerPlugin } from '@modern-js/server-core';
|
|
1
|
+
import type { ServerManifest, ServerPlugin } from '@modern-js/server-core';
|
|
2
|
+
import { InternalRequest } from '@modern-js/server-core';
|
|
2
3
|
declare module 'http' {
|
|
3
4
|
interface IncomingMessage {
|
|
4
|
-
__honoRequest
|
|
5
|
-
__templates
|
|
6
|
-
__serverManifest
|
|
5
|
+
__honoRequest?: InternalRequest;
|
|
6
|
+
__templates?: Record<string, string>;
|
|
7
|
+
__serverManifest?: ServerManifest;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
declare const _default: () => ServerPlugin;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.54.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/cli/index.js",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"koa-router": "^10.0.0",
|
|
68
68
|
"type-is": "^1.6.18",
|
|
69
69
|
"@swc/helpers": "0.5.3",
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
70
|
+
"@modern-js/types": "2.54.1",
|
|
71
|
+
"@modern-js/bff-core": "2.54.1",
|
|
72
|
+
"@modern-js/utils": "2.54.1",
|
|
73
|
+
"@modern-js/bff-runtime": "2.54.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/jest": "^29",
|
|
@@ -84,11 +84,11 @@
|
|
|
84
84
|
"supertest": "^6.1.6",
|
|
85
85
|
"typescript": "^5",
|
|
86
86
|
"zod": "^3.22.3",
|
|
87
|
-
"@modern-js/
|
|
88
|
-
"@modern-js/core": "2.
|
|
89
|
-
"@
|
|
90
|
-
"@scripts/
|
|
91
|
-
"@
|
|
87
|
+
"@modern-js/core": "2.54.1",
|
|
88
|
+
"@modern-js/server-core": "2.54.1",
|
|
89
|
+
"@modern-js/app-tools": "2.54.1",
|
|
90
|
+
"@scripts/build": "2.54.1",
|
|
91
|
+
"@scripts/jest-config": "2.54.1"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"koa": "^2.13.4"
|