@modern-js/plugin-express 2.52.0 → 2.54.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.
@@ -54,9 +54,9 @@ const expressPlugin = () => ({
54
54
  }
55
55
  };
56
56
  },
57
- collectServerPlugins({ plugins }) {
57
+ _internalServerPlugins({ plugins }) {
58
58
  plugins.push({
59
- "@modern-js/plugin-express": "@modern-js/plugin-express/server"
59
+ name: "@modern-js/plugin-express/server"
60
60
  });
61
61
  return {
62
62
  plugins
@@ -36,7 +36,7 @@ var import_express = __toESM(require("express"));
36
36
  var import_cookie_parser = __toESM(require("cookie-parser"));
37
37
  var import_utils = require("@modern-js/utils");
38
38
  var import_finalhandler = __toESM(require("finalhandler"));
39
- var import_node = require("@modern-js/server-core/base/node");
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) => {
@@ -104,7 +104,7 @@ const createApp = async ({ apiDir, middlewares, mode, apiHandlerInfos, render })
104
104
  }
105
105
  if (render) {
106
106
  app.use(async (req, res, next) => {
107
- const response = await render(req.__honoRequest, {
107
+ const response = await render(req.__honoRequest.raw, {
108
108
  logger: import_utils.logger,
109
109
  nodeReq: req,
110
110
  templates: req.__templates,
@@ -141,18 +141,19 @@ var plugin_default = () => {
141
141
  "@modern-js/plugin-server"
142
142
  ],
143
143
  setup: (api) => ({
144
- async onApiChange(changes) {
145
- const appContext = api.useAppContext();
146
- const middlewares = appContext.apiMiddlewares;
147
- const apiHandlerInfos = appContext.apiHandlerInfos;
148
- app = await createApp({
149
- apiDir,
150
- middlewares,
151
- mode,
152
- apiHandlerInfos,
153
- render: renderHtml
154
- });
155
- return changes;
144
+ async reset({ event }) {
145
+ if (event.type === "file-change") {
146
+ const appContext = api.useAppContext();
147
+ const middlewares = appContext.apiMiddlewares;
148
+ const apiHandlerInfos = appContext.apiHandlerInfos;
149
+ app = await createApp({
150
+ apiDir,
151
+ middlewares,
152
+ mode,
153
+ apiHandlerInfos,
154
+ render: renderHtml
155
+ });
156
+ }
156
157
  },
157
158
  async prepareApiServer({ pwd, render }) {
158
159
  var _userConfig_bff;
@@ -21,10 +21,10 @@ var expressPlugin = function() {
21
21
  }
22
22
  };
23
23
  },
24
- collectServerPlugins: function collectServerPlugins(param) {
24
+ _internalServerPlugins: function _internalServerPlugins(param) {
25
25
  var plugins = param.plugins;
26
26
  plugins.push({
27
- "@modern-js/plugin-express": "@modern-js/plugin-express/server"
27
+ name: "@modern-js/plugin-express/server"
28
28
  });
29
29
  return {
30
30
  plugins
@@ -5,7 +5,7 @@ import express from "express";
5
5
  import cookieParser from "cookie-parser";
6
6
  import { fs, compatRequire, logger } from "@modern-js/utils";
7
7
  import finalhandler from "finalhandler";
8
- import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/base/node";
8
+ import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/node";
9
9
  import { run } from "./context";
10
10
  import registerRoutes from "./registerRoutes";
11
11
  var findAppModule = function() {
@@ -175,7 +175,7 @@ var createApp = function() {
175
175
  case 0:
176
176
  return [
177
177
  4,
178
- render(req.__honoRequest, {
178
+ render(req.__honoRequest.raw, {
179
179
  logger,
180
180
  nodeReq: req,
181
181
  templates: req.__templates,
@@ -237,12 +237,18 @@ function plugin_default() {
237
237
  ],
238
238
  setup: function(api) {
239
239
  return {
240
- onApiChange: function onApiChange(changes) {
240
+ reset: function reset(param) {
241
+ var event = param.event;
241
242
  return _async_to_generator(function() {
242
243
  var appContext, middlewares, apiHandlerInfos;
243
244
  return _ts_generator(this, function(_state) {
244
245
  switch (_state.label) {
245
246
  case 0:
247
+ if (!(event.type === "file-change"))
248
+ return [
249
+ 3,
250
+ 2
251
+ ];
246
252
  appContext = api.useAppContext();
247
253
  middlewares = appContext.apiMiddlewares;
248
254
  apiHandlerInfos = appContext.apiHandlerInfos;
@@ -258,9 +264,10 @@ function plugin_default() {
258
264
  ];
259
265
  case 1:
260
266
  app = _state.sent();
267
+ _state.label = 2;
268
+ case 2:
261
269
  return [
262
- 2,
263
- changes
270
+ 2
264
271
  ];
265
272
  }
266
273
  });
@@ -20,9 +20,9 @@ const expressPlugin = () => ({
20
20
  }
21
21
  };
22
22
  },
23
- collectServerPlugins({ plugins }) {
23
+ _internalServerPlugins({ plugins }) {
24
24
  plugins.push({
25
- "@modern-js/plugin-express": "@modern-js/plugin-express/server"
25
+ name: "@modern-js/plugin-express/server"
26
26
  });
27
27
  return {
28
28
  plugins
@@ -3,7 +3,7 @@ import express from "express";
3
3
  import cookieParser from "cookie-parser";
4
4
  import { fs, compatRequire, logger } from "@modern-js/utils";
5
5
  import finalhandler from "finalhandler";
6
- import { httpCallBack2HonoMid, sendResponse } from "@modern-js/server-core/base/node";
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) => {
@@ -71,7 +71,7 @@ const createApp = async ({ apiDir, middlewares, mode, apiHandlerInfos, render })
71
71
  }
72
72
  if (render) {
73
73
  app.use(async (req, res, next) => {
74
- const response = await render(req.__honoRequest, {
74
+ const response = await render(req.__honoRequest.raw, {
75
75
  logger,
76
76
  nodeReq: req,
77
77
  templates: req.__templates,
@@ -108,18 +108,19 @@ var plugin_default = () => {
108
108
  "@modern-js/plugin-server"
109
109
  ],
110
110
  setup: (api) => ({
111
- async onApiChange(changes) {
112
- const appContext = api.useAppContext();
113
- const middlewares = appContext.apiMiddlewares;
114
- const apiHandlerInfos = appContext.apiHandlerInfos;
115
- app = await createApp({
116
- apiDir,
117
- middlewares,
118
- mode,
119
- apiHandlerInfos,
120
- render: renderHtml
121
- });
122
- return changes;
111
+ async reset({ event }) {
112
+ if (event.type === "file-change") {
113
+ const appContext = api.useAppContext();
114
+ const middlewares = appContext.apiMiddlewares;
115
+ const apiHandlerInfos = appContext.apiHandlerInfos;
116
+ app = await createApp({
117
+ apiDir,
118
+ middlewares,
119
+ mode,
120
+ apiHandlerInfos,
121
+ render: renderHtml
122
+ });
123
+ }
123
124
  },
124
125
  async prepareApiServer({ pwd, render }) {
125
126
  var _userConfig_bff;
@@ -1,10 +1,10 @@
1
- import type { ServerPlugin } from '@modern-js/server-core';
1
+ import type { ServerManifest, ServerPlugin, InternalRequest } from '@modern-js/server-core';
2
2
  declare global {
3
3
  namespace Express {
4
4
  interface Request {
5
- __honoRequest: globalThis.Request;
5
+ __honoRequest: InternalRequest;
6
6
  __templates: Record<string, string>;
7
- __serverManifest: any;
7
+ __serverManifest: ServerManifest;
8
8
  }
9
9
  }
10
10
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.52.0",
18
+ "version": "2.54.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "main": "./dist/cjs/cli/index.js",
@@ -49,10 +49,10 @@
49
49
  "reflect-metadata": "^0.1.13",
50
50
  "type-is": "^1.6.18",
51
51
  "@swc/helpers": "0.5.3",
52
- "@modern-js/bff-core": "2.52.0",
53
- "@modern-js/types": "2.52.0",
54
- "@modern-js/bff-runtime": "2.52.0",
55
- "@modern-js/utils": "2.52.0"
52
+ "@modern-js/bff-core": "2.54.0",
53
+ "@modern-js/bff-runtime": "2.54.0",
54
+ "@modern-js/types": "2.54.0",
55
+ "@modern-js/utils": "2.54.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/cookie-parser": "^1.4.2",
@@ -68,11 +68,11 @@
68
68
  "supertest": "^6.1.6",
69
69
  "typescript": "^5",
70
70
  "zod": "^3.22.3",
71
- "@modern-js/app-tools": "2.52.0",
72
- "@modern-js/server-core": "2.52.0",
73
- "@scripts/build": "2.52.0",
74
- "@modern-js/core": "2.52.0",
75
- "@scripts/jest-config": "2.52.0"
71
+ "@modern-js/core": "2.54.0",
72
+ "@modern-js/app-tools": "2.54.0",
73
+ "@modern-js/server-core": "2.54.0",
74
+ "@scripts/build": "2.54.0",
75
+ "@scripts/jest-config": "2.54.0"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "express": "^4.17.1"