@bleedingdev/modern-js-server-core 3.2.0-ultramodern.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/cjs/adapters/node/helper/index.js +55 -0
- package/dist/cjs/adapters/node/helper/loadCache.js +58 -0
- package/dist/cjs/adapters/node/helper/loadConfig.js +78 -0
- package/dist/cjs/adapters/node/helper/loadEnv.js +66 -0
- package/dist/cjs/adapters/node/helper/loadPlugin.js +47 -0
- package/dist/cjs/adapters/node/helper/utils.js +39 -0
- package/dist/cjs/adapters/node/hono.js +95 -0
- package/dist/cjs/adapters/node/index.js +87 -0
- package/dist/cjs/adapters/node/node.js +180 -0
- package/dist/cjs/adapters/node/plugins/index.js +72 -0
- package/dist/cjs/adapters/node/plugins/nodeServer.js +43 -0
- package/dist/cjs/adapters/node/plugins/resource.js +206 -0
- package/dist/cjs/adapters/node/plugins/static.js +379 -0
- package/dist/cjs/constants.js +77 -0
- package/dist/cjs/context.js +41 -0
- package/dist/cjs/helper.js +45 -0
- package/dist/cjs/hono.js +46 -0
- package/dist/cjs/index.js +247 -0
- package/dist/cjs/plugins/compat/hooks.js +80 -0
- package/dist/cjs/plugins/compat/index.js +64 -0
- package/dist/cjs/plugins/contractGateAutopilot.js +158 -0
- package/dist/cjs/plugins/contractGateSnapshotStore.js +239 -0
- package/dist/cjs/plugins/default.js +61 -0
- package/dist/cjs/plugins/favicon.js +48 -0
- package/dist/cjs/plugins/index.js +157 -0
- package/dist/cjs/plugins/log.js +92 -0
- package/dist/cjs/plugins/mfCache.js +78 -0
- package/dist/cjs/plugins/middlewares.js +49 -0
- package/dist/cjs/plugins/monitors.js +192 -0
- package/dist/cjs/plugins/processedBy.js +50 -0
- package/dist/cjs/plugins/render/csrRscRender.js +74 -0
- package/dist/cjs/plugins/render/dataHandler.js +53 -0
- package/dist/cjs/plugins/render/index.js +158 -0
- package/dist/cjs/plugins/render/inject.js +92 -0
- package/dist/cjs/plugins/render/render.js +273 -0
- package/dist/cjs/plugins/render/renderRscHandler.js +72 -0
- package/dist/cjs/plugins/render/serverActionHandler.js +47 -0
- package/dist/cjs/plugins/render/ssrCache.js +198 -0
- package/dist/cjs/plugins/render/ssrRender.js +96 -0
- package/dist/cjs/plugins/render/utils.js +49 -0
- package/dist/cjs/plugins/route.js +68 -0
- package/dist/cjs/plugins/telemetry.js +1283 -0
- package/dist/cjs/serverBase.js +176 -0
- package/dist/cjs/types/config/bff.js +18 -0
- package/dist/cjs/types/config/dev.js +18 -0
- package/dist/cjs/types/config/html.js +18 -0
- package/dist/cjs/types/config/index.js +93 -0
- package/dist/cjs/types/config/output.js +18 -0
- package/dist/cjs/types/config/security.js +18 -0
- package/dist/cjs/types/config/server.js +18 -0
- package/dist/cjs/types/config/share.js +18 -0
- package/dist/cjs/types/config/source.js +18 -0
- package/dist/cjs/types/config/tools.js +18 -0
- package/dist/cjs/types/index.js +79 -0
- package/dist/cjs/types/plugins/base.js +18 -0
- package/dist/cjs/types/plugins/index.js +58 -0
- package/dist/cjs/types/plugins/plugin.js +18 -0
- package/dist/cjs/types/render.js +18 -0
- package/dist/cjs/types/requestHandler.js +18 -0
- package/dist/cjs/types/server.js +18 -0
- package/dist/cjs/utils/entry.js +40 -0
- package/dist/cjs/utils/env.js +51 -0
- package/dist/cjs/utils/error.js +93 -0
- package/dist/cjs/utils/index.js +114 -0
- package/dist/cjs/utils/middlewareCollector.js +63 -0
- package/dist/cjs/utils/publicDir.js +92 -0
- package/dist/cjs/utils/request.js +86 -0
- package/dist/cjs/utils/serverConfig.js +43 -0
- package/dist/cjs/utils/storage.js +69 -0
- package/dist/cjs/utils/transformStream.js +65 -0
- package/dist/cjs/utils/warmup.js +40 -0
- package/dist/esm/adapters/node/helper/index.mjs +5 -0
- package/dist/esm/adapters/node/helper/loadCache.mjs +14 -0
- package/dist/esm/adapters/node/helper/loadConfig.mjs +31 -0
- package/dist/esm/adapters/node/helper/loadEnv.mjs +22 -0
- package/dist/esm/adapters/node/helper/loadPlugin.mjs +13 -0
- package/dist/esm/adapters/node/helper/utils.mjs +5 -0
- package/dist/esm/adapters/node/hono.mjs +55 -0
- package/dist/esm/adapters/node/index.mjs +4 -0
- package/dist/esm/adapters/node/node.mjs +130 -0
- package/dist/esm/adapters/node/plugins/index.mjs +3 -0
- package/dist/esm/adapters/node/plugins/nodeServer.mjs +9 -0
- package/dist/esm/adapters/node/plugins/resource.mjs +138 -0
- package/dist/esm/adapters/node/plugins/static.mjs +329 -0
- package/dist/esm/constants.mjs +28 -0
- package/dist/esm/context.mjs +4 -0
- package/dist/esm/helper.mjs +11 -0
- package/dist/esm/hono.mjs +2 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/plugins/compat/hooks.mjs +40 -0
- package/dist/esm/plugins/compat/index.mjs +27 -0
- package/dist/esm/plugins/contractGateAutopilot.mjs +124 -0
- package/dist/esm/plugins/contractGateSnapshotStore.mjs +180 -0
- package/dist/esm/plugins/default.mjs +27 -0
- package/dist/esm/plugins/favicon.mjs +14 -0
- package/dist/esm/plugins/index.mjs +11 -0
- package/dist/esm/plugins/log.mjs +58 -0
- package/dist/esm/plugins/mfCache.mjs +35 -0
- package/dist/esm/plugins/middlewares.mjs +15 -0
- package/dist/esm/plugins/monitors.mjs +149 -0
- package/dist/esm/plugins/processedBy.mjs +16 -0
- package/dist/esm/plugins/render/csrRscRender.mjs +40 -0
- package/dist/esm/plugins/render/dataHandler.mjs +19 -0
- package/dist/esm/plugins/render/index.mjs +84 -0
- package/dist/esm/plugins/render/inject.mjs +55 -0
- package/dist/esm/plugins/render/render.mjs +230 -0
- package/dist/esm/plugins/render/renderRscHandler.mjs +38 -0
- package/dist/esm/plugins/render/serverActionHandler.mjs +13 -0
- package/dist/esm/plugins/render/ssrCache.mjs +158 -0
- package/dist/esm/plugins/render/ssrRender.mjs +62 -0
- package/dist/esm/plugins/render/utils.mjs +15 -0
- package/dist/esm/plugins/route.mjs +34 -0
- package/dist/esm/plugins/telemetry.mjs +1195 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/serverBase.mjs +139 -0
- package/dist/esm/types/config/bff.mjs +0 -0
- package/dist/esm/types/config/dev.mjs +0 -0
- package/dist/esm/types/config/html.mjs +0 -0
- package/dist/esm/types/config/index.mjs +6 -0
- package/dist/esm/types/config/output.mjs +0 -0
- package/dist/esm/types/config/security.mjs +0 -0
- package/dist/esm/types/config/server.mjs +0 -0
- package/dist/esm/types/config/share.mjs +0 -0
- package/dist/esm/types/config/source.mjs +0 -0
- package/dist/esm/types/config/tools.mjs +0 -0
- package/dist/esm/types/index.mjs +4 -0
- package/dist/esm/types/plugins/base.mjs +0 -0
- package/dist/esm/types/plugins/index.mjs +1 -0
- package/dist/esm/types/plugins/plugin.mjs +0 -0
- package/dist/esm/types/render.mjs +0 -0
- package/dist/esm/types/requestHandler.mjs +0 -0
- package/dist/esm/types/server.mjs +0 -0
- package/dist/esm/utils/entry.mjs +3 -0
- package/dist/esm/utils/env.mjs +14 -0
- package/dist/esm/utils/error.mjs +53 -0
- package/dist/esm/utils/index.mjs +9 -0
- package/dist/esm/utils/middlewareCollector.mjs +26 -0
- package/dist/esm/utils/publicDir.mjs +33 -0
- package/dist/esm/utils/request.mjs +40 -0
- package/dist/esm/utils/serverConfig.mjs +9 -0
- package/dist/esm/utils/storage.mjs +35 -0
- package/dist/esm/utils/transformStream.mjs +28 -0
- package/dist/esm/utils/warmup.mjs +6 -0
- package/dist/esm-node/adapters/node/helper/index.mjs +6 -0
- package/dist/esm-node/adapters/node/helper/loadCache.mjs +15 -0
- package/dist/esm-node/adapters/node/helper/loadConfig.mjs +32 -0
- package/dist/esm-node/adapters/node/helper/loadEnv.mjs +23 -0
- package/dist/esm-node/adapters/node/helper/loadPlugin.mjs +14 -0
- package/dist/esm-node/adapters/node/helper/utils.mjs +6 -0
- package/dist/esm-node/adapters/node/hono.mjs +56 -0
- package/dist/esm-node/adapters/node/index.mjs +5 -0
- package/dist/esm-node/adapters/node/node.mjs +131 -0
- package/dist/esm-node/adapters/node/plugins/index.mjs +4 -0
- package/dist/esm-node/adapters/node/plugins/nodeServer.mjs +10 -0
- package/dist/esm-node/adapters/node/plugins/resource.mjs +139 -0
- package/dist/esm-node/adapters/node/plugins/static.mjs +330 -0
- package/dist/esm-node/constants.mjs +29 -0
- package/dist/esm-node/context.mjs +5 -0
- package/dist/esm-node/helper.mjs +12 -0
- package/dist/esm-node/hono.mjs +3 -0
- package/dist/esm-node/index.mjs +13 -0
- package/dist/esm-node/plugins/compat/hooks.mjs +41 -0
- package/dist/esm-node/plugins/compat/index.mjs +28 -0
- package/dist/esm-node/plugins/contractGateAutopilot.mjs +125 -0
- package/dist/esm-node/plugins/contractGateSnapshotStore.mjs +182 -0
- package/dist/esm-node/plugins/default.mjs +28 -0
- package/dist/esm-node/plugins/favicon.mjs +15 -0
- package/dist/esm-node/plugins/index.mjs +12 -0
- package/dist/esm-node/plugins/log.mjs +59 -0
- package/dist/esm-node/plugins/mfCache.mjs +36 -0
- package/dist/esm-node/plugins/middlewares.mjs +16 -0
- package/dist/esm-node/plugins/monitors.mjs +150 -0
- package/dist/esm-node/plugins/processedBy.mjs +17 -0
- package/dist/esm-node/plugins/render/csrRscRender.mjs +41 -0
- package/dist/esm-node/plugins/render/dataHandler.mjs +20 -0
- package/dist/esm-node/plugins/render/index.mjs +85 -0
- package/dist/esm-node/plugins/render/inject.mjs +56 -0
- package/dist/esm-node/plugins/render/render.mjs +231 -0
- package/dist/esm-node/plugins/render/renderRscHandler.mjs +39 -0
- package/dist/esm-node/plugins/render/serverActionHandler.mjs +14 -0
- package/dist/esm-node/plugins/render/ssrCache.mjs +159 -0
- package/dist/esm-node/plugins/render/ssrRender.mjs +63 -0
- package/dist/esm-node/plugins/render/utils.mjs +16 -0
- package/dist/esm-node/plugins/route.mjs +35 -0
- package/dist/esm-node/plugins/telemetry.mjs +1196 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/esm-node/serverBase.mjs +140 -0
- package/dist/esm-node/types/config/bff.mjs +1 -0
- package/dist/esm-node/types/config/dev.mjs +1 -0
- package/dist/esm-node/types/config/html.mjs +1 -0
- package/dist/esm-node/types/config/index.mjs +7 -0
- package/dist/esm-node/types/config/output.mjs +1 -0
- package/dist/esm-node/types/config/security.mjs +1 -0
- package/dist/esm-node/types/config/server.mjs +1 -0
- package/dist/esm-node/types/config/share.mjs +1 -0
- package/dist/esm-node/types/config/source.mjs +1 -0
- package/dist/esm-node/types/config/tools.mjs +1 -0
- package/dist/esm-node/types/index.mjs +5 -0
- package/dist/esm-node/types/plugins/base.mjs +1 -0
- package/dist/esm-node/types/plugins/index.mjs +2 -0
- package/dist/esm-node/types/plugins/plugin.mjs +1 -0
- package/dist/esm-node/types/render.mjs +1 -0
- package/dist/esm-node/types/requestHandler.mjs +1 -0
- package/dist/esm-node/types/server.mjs +1 -0
- package/dist/esm-node/utils/entry.mjs +4 -0
- package/dist/esm-node/utils/env.mjs +15 -0
- package/dist/esm-node/utils/error.mjs +54 -0
- package/dist/esm-node/utils/index.mjs +10 -0
- package/dist/esm-node/utils/middlewareCollector.mjs +27 -0
- package/dist/esm-node/utils/publicDir.mjs +34 -0
- package/dist/esm-node/utils/request.mjs +41 -0
- package/dist/esm-node/utils/serverConfig.mjs +10 -0
- package/dist/esm-node/utils/storage.mjs +36 -0
- package/dist/esm-node/utils/transformStream.mjs +29 -0
- package/dist/esm-node/utils/warmup.mjs +7 -0
- package/dist/types/adapters/node/helper/index.d.ts +6 -0
- package/dist/types/adapters/node/helper/loadCache.d.ts +2 -0
- package/dist/types/adapters/node/helper/loadConfig.d.ts +3 -0
- package/dist/types/adapters/node/helper/loadEnv.d.ts +3 -0
- package/dist/types/adapters/node/helper/loadPlugin.d.ts +3 -0
- package/dist/types/adapters/node/helper/utils.d.ts +21 -0
- package/dist/types/adapters/node/hono.d.ts +19 -0
- package/dist/types/adapters/node/index.d.ts +5 -0
- package/dist/types/adapters/node/node.d.ts +17 -0
- package/dist/types/adapters/node/plugins/index.d.ts +3 -0
- package/dist/types/adapters/node/plugins/nodeServer.d.ts +6 -0
- package/dist/types/adapters/node/plugins/resource.d.ts +11 -0
- package/dist/types/adapters/node/plugins/static.d.ts +25 -0
- package/dist/types/constants.d.ts +26 -0
- package/dist/types/context.d.ts +3 -0
- package/dist/types/helper.d.ts +10 -0
- package/dist/types/hono.d.ts +3 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/plugins/compat/hooks.d.ts +8 -0
- package/dist/types/plugins/compat/index.d.ts +3 -0
- package/dist/types/plugins/contractGateAutopilot.d.ts +35 -0
- package/dist/types/plugins/contractGateSnapshotStore.d.ts +57 -0
- package/dist/types/plugins/default.d.ts +7 -0
- package/dist/types/plugins/favicon.d.ts +2 -0
- package/dist/types/plugins/index.d.ts +11 -0
- package/dist/types/plugins/log.d.ts +2 -0
- package/dist/types/plugins/mfCache.d.ts +12 -0
- package/dist/types/plugins/middlewares.d.ts +2 -0
- package/dist/types/plugins/monitors.d.ts +6 -0
- package/dist/types/plugins/processedBy.d.ts +2 -0
- package/dist/types/plugins/render/csrRscRender.d.ts +2 -0
- package/dist/types/plugins/render/dataHandler.d.ts +5 -0
- package/dist/types/plugins/render/index.d.ts +3 -0
- package/dist/types/plugins/render/inject.d.ts +7 -0
- package/dist/types/plugins/render/render.d.ts +16 -0
- package/dist/types/plugins/render/renderRscHandler.d.ts +2 -0
- package/dist/types/plugins/render/serverActionHandler.d.ts +2 -0
- package/dist/types/plugins/render/ssrCache.d.ts +18 -0
- package/dist/types/plugins/render/ssrRender.d.ts +26 -0
- package/dist/types/plugins/render/utils.d.ts +3 -0
- package/dist/types/plugins/route.d.ts +2 -0
- package/dist/types/plugins/telemetry.d.ts +309 -0
- package/dist/types/serverBase.d.ts +38 -0
- package/dist/types/types/config/bff.d.ts +142 -0
- package/dist/types/types/config/dev.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +15 -0
- package/dist/types/types/config/index.d.ts +35 -0
- package/dist/types/types/config/output.d.ts +20 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/server.d.ts +402 -0
- package/dist/types/types/config/share.d.ts +3 -0
- package/dist/types/types/config/source.d.ts +7 -0
- package/dist/types/types/config/tools.d.ts +2 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/plugins/base.d.ts +57 -0
- package/dist/types/types/plugins/index.d.ts +2 -0
- package/dist/types/types/plugins/plugin.d.ts +31 -0
- package/dist/types/types/render.d.ts +24 -0
- package/dist/types/types/requestHandler.d.ts +48 -0
- package/dist/types/types/server.d.ts +67 -0
- package/dist/types/utils/entry.d.ts +3 -0
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/error.d.ts +8 -0
- package/dist/types/utils/index.d.ts +9 -0
- package/dist/types/utils/middlewareCollector.d.ts +12 -0
- package/dist/types/utils/publicDir.d.ts +40 -0
- package/dist/types/utils/request.d.ts +17 -0
- package/dist/types/utils/serverConfig.d.ts +8 -0
- package/dist/types/utils/storage.d.ts +5 -0
- package/dist/types/utils/transformStream.d.ts +5 -0
- package/dist/types/utils/warmup.d.ts +1 -0
- package/package.json +103 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +7 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { server as server_server } from "@modern-js/plugin/server";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { run } from "./context.mjs";
|
|
4
|
+
import { handleSetupResult } from "./plugins/compat/hooks.mjs";
|
|
5
|
+
import { loadConfig } from "./utils/index.mjs";
|
|
6
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
7
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
8
|
+
}
|
|
9
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
10
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
11
|
+
return fn;
|
|
12
|
+
}
|
|
13
|
+
function _class_private_method_init(obj, privateSet) {
|
|
14
|
+
_check_private_redeclaration(obj, privateSet);
|
|
15
|
+
privateSet.add(obj);
|
|
16
|
+
}
|
|
17
|
+
var _applyMiddlewares = /*#__PURE__*/ new WeakSet();
|
|
18
|
+
class ServerBase {
|
|
19
|
+
async init() {
|
|
20
|
+
const { serverConfig, config: cliConfig } = this.serverOptions;
|
|
21
|
+
const mergedConfig = loadConfig({
|
|
22
|
+
cliConfig,
|
|
23
|
+
serverConfig: serverConfig || {}
|
|
24
|
+
});
|
|
25
|
+
const { serverContext } = await server_server.run({
|
|
26
|
+
plugins: this.plugins,
|
|
27
|
+
options: this.serverOptions,
|
|
28
|
+
config: mergedConfig,
|
|
29
|
+
handleSetupResult: handleSetupResult
|
|
30
|
+
});
|
|
31
|
+
serverContext.serverBase = this;
|
|
32
|
+
this.serverContext = serverContext;
|
|
33
|
+
await serverContext.hooks.onPrepare.call();
|
|
34
|
+
_class_private_method_get(this, _applyMiddlewares, applyMiddlewares).call(this);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
addPlugins(plugins) {
|
|
38
|
+
this.plugins.push(...plugins);
|
|
39
|
+
}
|
|
40
|
+
get hooks() {
|
|
41
|
+
return this.serverContext.hooks;
|
|
42
|
+
}
|
|
43
|
+
get all() {
|
|
44
|
+
return this.app.all.bind(this.app);
|
|
45
|
+
}
|
|
46
|
+
get use() {
|
|
47
|
+
return this.app.use.bind(this.app);
|
|
48
|
+
}
|
|
49
|
+
get get() {
|
|
50
|
+
return this.app.get.bind(this.app);
|
|
51
|
+
}
|
|
52
|
+
get options() {
|
|
53
|
+
return this.app.options.bind(this.app);
|
|
54
|
+
}
|
|
55
|
+
get post() {
|
|
56
|
+
return this.app.post.bind(this.app);
|
|
57
|
+
}
|
|
58
|
+
get put() {
|
|
59
|
+
return this.app.put.bind(this.app);
|
|
60
|
+
}
|
|
61
|
+
get delete() {
|
|
62
|
+
return this.app.delete.bind(this.app);
|
|
63
|
+
}
|
|
64
|
+
get patch() {
|
|
65
|
+
return this.app.patch.bind(this.app);
|
|
66
|
+
}
|
|
67
|
+
get handle() {
|
|
68
|
+
return this.app.fetch.bind(this.app);
|
|
69
|
+
}
|
|
70
|
+
get request() {
|
|
71
|
+
return this.app.request.bind(this.app);
|
|
72
|
+
}
|
|
73
|
+
get notFound() {
|
|
74
|
+
return this.app.notFound.bind(this.app);
|
|
75
|
+
}
|
|
76
|
+
get onError() {
|
|
77
|
+
return this.app.onError.bind(this.app);
|
|
78
|
+
}
|
|
79
|
+
constructor(options){
|
|
80
|
+
_class_private_method_init(this, _applyMiddlewares);
|
|
81
|
+
this.plugins = [];
|
|
82
|
+
this.serverContext = null;
|
|
83
|
+
this.serverOptions = options;
|
|
84
|
+
this.app = new Hono();
|
|
85
|
+
this.app.use('*', run);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function applyMiddlewares() {
|
|
89
|
+
const { middlewares } = this.serverContext;
|
|
90
|
+
const preMiddlewares = [];
|
|
91
|
+
const defaultMiddlewares = [];
|
|
92
|
+
const postMiddlewares = [];
|
|
93
|
+
for (const middleware of middlewares)switch(middleware.order){
|
|
94
|
+
case 'pre':
|
|
95
|
+
preMiddlewares.push(middleware);
|
|
96
|
+
break;
|
|
97
|
+
case 'post':
|
|
98
|
+
postMiddlewares.push(middleware);
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
defaultMiddlewares.push(middleware);
|
|
102
|
+
}
|
|
103
|
+
const finalMiddlewares = [];
|
|
104
|
+
const insertMiddleware = (middleware)=>{
|
|
105
|
+
if (middleware.before) {
|
|
106
|
+
const targetIndex = finalMiddlewares.findIndex((item)=>{
|
|
107
|
+
if (middleware.before?.includes(item.name)) return true;
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
110
|
+
if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
|
|
111
|
+
else finalMiddlewares.push(middleware);
|
|
112
|
+
} else finalMiddlewares.push(middleware);
|
|
113
|
+
};
|
|
114
|
+
preMiddlewares.forEach(insertMiddleware);
|
|
115
|
+
defaultMiddlewares.forEach(insertMiddleware);
|
|
116
|
+
postMiddlewares.forEach(insertMiddleware);
|
|
117
|
+
for (const middleware of finalMiddlewares){
|
|
118
|
+
const { path = '*', method = 'all', handler } = middleware;
|
|
119
|
+
const handlers = handler2Handlers(handler);
|
|
120
|
+
if (0 === handlers.length) continue;
|
|
121
|
+
const firstHandler = handlers[0];
|
|
122
|
+
const restHandlers = handlers.slice(1);
|
|
123
|
+
const m = method;
|
|
124
|
+
const register = this.app[m];
|
|
125
|
+
register.call(this.app, path, firstHandler, ...restHandlers);
|
|
126
|
+
}
|
|
127
|
+
function handler2Handlers(handler) {
|
|
128
|
+
if (Array.isArray(handler)) return handler;
|
|
129
|
+
return [
|
|
130
|
+
handler
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function createServerBase(options) {
|
|
135
|
+
if (null == options) throw new Error('can not start server without options');
|
|
136
|
+
const server = new ServerBase(options);
|
|
137
|
+
return server;
|
|
138
|
+
}
|
|
139
|
+
export { ServerBase, createServerBase };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./plugin.mjs";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const getRuntimeEnv = ()=>{
|
|
2
|
+
if (globalThis?.process?.release?.name === 'node') return 'node';
|
|
3
|
+
return 'other';
|
|
4
|
+
};
|
|
5
|
+
const checkIsProd = ()=>{
|
|
6
|
+
const env = getRuntimeEnv();
|
|
7
|
+
switch(env){
|
|
8
|
+
case 'node':
|
|
9
|
+
return 'production' === process.env.NODE_ENV;
|
|
10
|
+
default:
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export { checkIsProd, getRuntimeEnv };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseHeaders } from "./request.mjs";
|
|
2
|
+
const ERROR_PAGE_TEXT = {
|
|
3
|
+
404: 'This page could not be found.',
|
|
4
|
+
500: 'Internal Server Error.'
|
|
5
|
+
};
|
|
6
|
+
const createErrorHtml = (status)=>{
|
|
7
|
+
const text = ERROR_PAGE_TEXT[status] || '';
|
|
8
|
+
const title = `${status}: ${text}`;
|
|
9
|
+
return `<!DOCTYPE html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8">
|
|
13
|
+
<meta name="viewport" content="width=device-width">
|
|
14
|
+
<title>${title}</title>
|
|
15
|
+
<style>
|
|
16
|
+
html,body {
|
|
17
|
+
margin: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.page-container {
|
|
21
|
+
color: #000;
|
|
22
|
+
background: #fff;
|
|
23
|
+
height: 100vh;
|
|
24
|
+
text-align: center;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div class="page-container">
|
|
34
|
+
<h1>${status}</h1>
|
|
35
|
+
<div>${text}</div>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
38
|
+
`;
|
|
39
|
+
};
|
|
40
|
+
var error_ErrorDigest = /*#__PURE__*/ function(ErrorDigest) {
|
|
41
|
+
ErrorDigest["ENOTF"] = "Page could not be found";
|
|
42
|
+
ErrorDigest["EINTER"] = "Internal server error";
|
|
43
|
+
ErrorDigest["ERENDER"] = "SSR render fallback";
|
|
44
|
+
return ErrorDigest;
|
|
45
|
+
}({});
|
|
46
|
+
function onError(digest, error, monitors, req) {
|
|
47
|
+
const headerData = req && parseHeaders(req);
|
|
48
|
+
headerData && delete headerData.cookie;
|
|
49
|
+
if (monitors) monitors.error(req ? `Server Error - ${digest}, error = %s, req.url = %s, req.headers = %o` : `Server Error - ${digest}, error = %s`, error instanceof Error ? error.stack || error.message : error, req?.url, headerData);
|
|
50
|
+
else if (req) console.error(`Server Error - ${digest}, error = ${error instanceof Error ? error.stack || error.message : error}, req.url = ${req.url}, req.headers = ${JSON.stringify(headerData)}`);
|
|
51
|
+
else console.error(`Server Error - ${digest}, error = ${error instanceof Error ? error.stack || error.message : error} `);
|
|
52
|
+
}
|
|
53
|
+
export { createErrorHtml, error_ErrorDigest as ErrorDigest, onError };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./entry.mjs";
|
|
2
|
+
export * from "./env.mjs";
|
|
3
|
+
export * from "./error.mjs";
|
|
4
|
+
export * from "./middlewareCollector.mjs";
|
|
5
|
+
export * from "./publicDir.mjs";
|
|
6
|
+
export * from "./request.mjs";
|
|
7
|
+
export * from "./serverConfig.mjs";
|
|
8
|
+
export * from "./transformStream.mjs";
|
|
9
|
+
export * from "./warmup.mjs";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const mergeExtension = (users)=>{
|
|
2
|
+
const output = [];
|
|
3
|
+
return {
|
|
4
|
+
middleware: output.concat(users)
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
const createMiddlewareCollecter = ()=>{
|
|
8
|
+
const webMiddlewares = [];
|
|
9
|
+
const apiMiddlewares = [];
|
|
10
|
+
const addWebMiddleware = (input)=>{
|
|
11
|
+
webMiddlewares.push(input);
|
|
12
|
+
};
|
|
13
|
+
const addAPIMiddleware = (input)=>{
|
|
14
|
+
apiMiddlewares.push(input);
|
|
15
|
+
};
|
|
16
|
+
const getMiddlewares = ()=>({
|
|
17
|
+
web: webMiddlewares,
|
|
18
|
+
api: apiMiddlewares
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
getMiddlewares,
|
|
22
|
+
addWebMiddleware,
|
|
23
|
+
addAPIMiddleware
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export { createMiddlewareCollecter, mergeExtension };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
function normalizePublicDir(publicDir) {
|
|
3
|
+
if (!publicDir) return [];
|
|
4
|
+
return Array.isArray(publicDir) ? publicDir : [
|
|
5
|
+
publicDir
|
|
6
|
+
];
|
|
7
|
+
}
|
|
8
|
+
function normalizePublicDirPath(dir) {
|
|
9
|
+
return dir.replace(/^\.\//, '').replace(/\/$/, '');
|
|
10
|
+
}
|
|
11
|
+
function getPublicDirRoutePrefixes(publicDir) {
|
|
12
|
+
const dirs = normalizePublicDir(publicDir);
|
|
13
|
+
return dirs.map((dir)=>{
|
|
14
|
+
const normalized = normalizePublicDirPath(dir);
|
|
15
|
+
return `/${normalized}`;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function getPublicDirPatterns(publicDir) {
|
|
19
|
+
const dirs = normalizePublicDir(publicDir);
|
|
20
|
+
return dirs.map((dir)=>{
|
|
21
|
+
const normalized = normalizePublicDirPath(dir);
|
|
22
|
+
return `${normalized}/`;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function resolvePublicDirPaths(publicDir, appDirectory) {
|
|
26
|
+
const dirs = normalizePublicDir(publicDir);
|
|
27
|
+
if (!appDirectory) return dirs;
|
|
28
|
+
return dirs.map((dir)=>path.resolve(appDirectory, dir));
|
|
29
|
+
}
|
|
30
|
+
function getPublicDirConfig(serverConfig) {
|
|
31
|
+
return serverConfig?.publicDir;
|
|
32
|
+
}
|
|
33
|
+
export { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function parseQuery(req) {
|
|
2
|
+
const query = {};
|
|
3
|
+
const { url } = req;
|
|
4
|
+
const q = url.split('?')[1];
|
|
5
|
+
if (q) {
|
|
6
|
+
const search = new URLSearchParams(q);
|
|
7
|
+
search.forEach((v, k)=>{
|
|
8
|
+
query[k] = v;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return query;
|
|
12
|
+
}
|
|
13
|
+
function parseHeaders(request) {
|
|
14
|
+
const headersData = {};
|
|
15
|
+
request.headers.forEach((value, key)=>{
|
|
16
|
+
headersData[key] = value;
|
|
17
|
+
});
|
|
18
|
+
return headersData;
|
|
19
|
+
}
|
|
20
|
+
function getPathname(request) {
|
|
21
|
+
const match = request.url.match(/^https?:\/\/[^/]+(\/[^?]*)/);
|
|
22
|
+
return match?.[1] ?? '/';
|
|
23
|
+
}
|
|
24
|
+
function getHost(request) {
|
|
25
|
+
const { headers } = request;
|
|
26
|
+
let host = headers.get('X-Forwarded-Host');
|
|
27
|
+
if (!host) host = headers.get('Host');
|
|
28
|
+
host = host?.split(/\s*,\s*/, 1)[0] || 'undefined';
|
|
29
|
+
return host;
|
|
30
|
+
}
|
|
31
|
+
function parseCookie(req) {
|
|
32
|
+
const _cookie = req.headers.get('Cookie');
|
|
33
|
+
const cookie = {};
|
|
34
|
+
_cookie?.trim().split(';').forEach((item)=>{
|
|
35
|
+
const [k, v] = item.trim().split('=');
|
|
36
|
+
if (k && void 0 !== v) cookie[k] = v;
|
|
37
|
+
});
|
|
38
|
+
return cookie;
|
|
39
|
+
}
|
|
40
|
+
export { getHost, getPathname, parseCookie, parseHeaders, parseQuery };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as __rspack_external_async_hooks from "async_hooks";
|
|
2
|
+
const createStorage = (storageKey)=>{
|
|
3
|
+
let storage;
|
|
4
|
+
if (void 0 !== __rspack_external_async_hooks.AsyncLocalStorage) if (storageKey) {
|
|
5
|
+
const globalStore = globalThis;
|
|
6
|
+
const sharedStorage = globalStore[storageKey];
|
|
7
|
+
storage = sharedStorage ?? new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
8
|
+
globalStore[storageKey] = storage;
|
|
9
|
+
} else storage = new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
10
|
+
const run = (context, cb)=>{
|
|
11
|
+
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
12
|
+
`);
|
|
13
|
+
return new Promise((resolve, reject)=>{
|
|
14
|
+
storage.run(context, ()=>{
|
|
15
|
+
try {
|
|
16
|
+
return resolve(cb());
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return reject(error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const useContext = ()=>{
|
|
24
|
+
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
25
|
+
`);
|
|
26
|
+
const context = storage.getStore();
|
|
27
|
+
if (!context) throw new Error("Can't call context hook out of server scope");
|
|
28
|
+
return context;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
run,
|
|
32
|
+
useContext
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export { createStorage };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function createTransformStream(fn) {
|
|
2
|
+
const decoder = new TextDecoder();
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
return new TransformStream({
|
|
5
|
+
async transform (chunk, controller) {
|
|
6
|
+
const content = decoder.decode(chunk);
|
|
7
|
+
const newContent = fn ? await fn(content) : content;
|
|
8
|
+
controller.enqueue(encoder.encode(newContent));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function transformResponse(response, transformCb) {
|
|
13
|
+
let readable = null;
|
|
14
|
+
if (response.body) {
|
|
15
|
+
const stream = createTransformStream(async (before)=>{
|
|
16
|
+
if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
|
|
17
|
+
return transformCb(before);
|
|
18
|
+
});
|
|
19
|
+
response.body.pipeThrough(stream);
|
|
20
|
+
readable = stream.readable;
|
|
21
|
+
}
|
|
22
|
+
return new Response(readable, {
|
|
23
|
+
status: response.status,
|
|
24
|
+
headers: response.headers,
|
|
25
|
+
statusText: response.statusText
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { createTransformStream, transformResponse };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { loadCacheConfig } from "./loadCache.mjs";
|
|
3
|
+
export { loadServerCliConfig, loadServerRuntimeConfig } from "./loadConfig.mjs";
|
|
4
|
+
export { loadServerEnv } from "./loadEnv.mjs";
|
|
5
|
+
export { loadServerPlugins } from "./loadPlugin.mjs";
|
|
6
|
+
export { isResFinalized } from "./utils.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { SERVER_DIR, requireExistModule } from "@modern-js/utils";
|
|
3
|
+
import path from "path";
|
|
4
|
+
const CACHE_FILENAME = 'cache';
|
|
5
|
+
async function loadCacheConfig(pwd) {
|
|
6
|
+
const serverCacheFilepath = path.resolve(pwd, SERVER_DIR, CACHE_FILENAME);
|
|
7
|
+
const mod = await requireExistModule(serverCacheFilepath, {
|
|
8
|
+
interop: false
|
|
9
|
+
});
|
|
10
|
+
if (mod?.cacheOption) return {
|
|
11
|
+
strategy: mod.cacheOption,
|
|
12
|
+
container: mod.customContainer
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export { loadCacheConfig };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { OUTPUT_CONFIG_FILE, ensureAbsolutePath, fs as utils_fs, lodash, requireExistModule } from "@modern-js/utils";
|
|
3
|
+
import { parse } from "flatted";
|
|
4
|
+
import path_0 from "path";
|
|
5
|
+
async function loadServerConfigNew(serverConfigPath) {
|
|
6
|
+
const mod = await requireExistModule(serverConfigPath);
|
|
7
|
+
if (mod) return mod;
|
|
8
|
+
}
|
|
9
|
+
async function loadServerRuntimeConfig(serverConfigPath) {
|
|
10
|
+
const newServerConfig = await loadServerConfigNew(serverConfigPath);
|
|
11
|
+
return newServerConfig;
|
|
12
|
+
}
|
|
13
|
+
function loadServerCliConfig(pwd, defaultConfig = {}) {
|
|
14
|
+
const cliConfigPath = ensureAbsolutePath(pwd, path_0.join(defaultConfig.output?.distPath?.root || 'dist', OUTPUT_CONFIG_FILE));
|
|
15
|
+
let cliConfig = {
|
|
16
|
+
output: {},
|
|
17
|
+
source: {},
|
|
18
|
+
tools: {},
|
|
19
|
+
server: {},
|
|
20
|
+
security: {},
|
|
21
|
+
bff: {},
|
|
22
|
+
html: {},
|
|
23
|
+
dev: {}
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
const content = utils_fs.readFileSync(cliConfigPath, 'utf-8');
|
|
27
|
+
cliConfig = parse(content);
|
|
28
|
+
} catch (_) {}
|
|
29
|
+
const mergedCliConfig = lodash.merge(defaultConfig, cliConfig);
|
|
30
|
+
return mergedCliConfig;
|
|
31
|
+
}
|
|
32
|
+
export { loadServerCliConfig, loadServerRuntimeConfig };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { dotenv, dotenvExpand, fs } from "@modern-js/utils";
|
|
3
|
+
import path from "path";
|
|
4
|
+
async function loadServerEnv(options) {
|
|
5
|
+
const { pwd } = options;
|
|
6
|
+
const serverEnv = process.env.MODERN_ENV;
|
|
7
|
+
const defaultEnvPath = path.resolve(pwd, ".env");
|
|
8
|
+
const serverEnvPath = path.resolve(pwd, `.env.${serverEnv}`);
|
|
9
|
+
if (await fs.pathExists(defaultEnvPath) && !(await fs.stat(defaultEnvPath)).isDirectory()) {
|
|
10
|
+
const envConfig = dotenv.config({
|
|
11
|
+
path: defaultEnvPath
|
|
12
|
+
});
|
|
13
|
+
dotenvExpand(envConfig);
|
|
14
|
+
}
|
|
15
|
+
if (await fs.pathExists(serverEnvPath) && !(await fs.stat(serverEnvPath)).isDirectory()) {
|
|
16
|
+
const envConfig = dotenv.config({
|
|
17
|
+
path: serverEnvPath
|
|
18
|
+
});
|
|
19
|
+
if (envConfig.parsed) Object.assign(process.env, envConfig.parsed);
|
|
20
|
+
dotenvExpand(envConfig);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export { loadServerEnv };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { compatibleRequire, tryResolve } from "@modern-js/utils";
|
|
3
|
+
async function resolveServerPlugin(plugin, appDirectory) {
|
|
4
|
+
const { name, options } = plugin;
|
|
5
|
+
const pluginPath = tryResolve(name, appDirectory);
|
|
6
|
+
const module = await compatibleRequire(pluginPath);
|
|
7
|
+
const pluginInstance = module(options);
|
|
8
|
+
return pluginInstance;
|
|
9
|
+
}
|
|
10
|
+
async function loadServerPlugins(serverPlugins, appDirectory) {
|
|
11
|
+
const instances = await Promise.all(serverPlugins.map((plugin)=>resolveServerPlugin(plugin, appDirectory)));
|
|
12
|
+
return instances;
|
|
13
|
+
}
|
|
14
|
+
export { loadServerPlugins };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const isResFinalized = (res)=>{
|
|
3
|
+
const response = res;
|
|
4
|
+
return Boolean(response.headersSent) || Boolean(response._modernBodyPiped) || Boolean(response.writableEnded) || Boolean(response.finished) || response.socket?.writable === false;
|
|
5
|
+
};
|
|
6
|
+
export { isResFinalized };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { isResFinalized } from "./helper/index.mjs";
|
|
3
|
+
const httpCallBack2HonoMid = (handler)=>async (context, next)=>{
|
|
4
|
+
const { req, res: rawRes } = context.env.node;
|
|
5
|
+
const res = rawRes;
|
|
6
|
+
const onPipe = ()=>{
|
|
7
|
+
res._modernBodyPiped = true;
|
|
8
|
+
};
|
|
9
|
+
res.once?.('pipe', onPipe);
|
|
10
|
+
req.__honoRequest = context.req;
|
|
11
|
+
req.__templates = context.get('templates') || {};
|
|
12
|
+
req.__serverManifest = context.get('serverManifest') || {};
|
|
13
|
+
req.__rscServerManifest = context.get('rscServerManifest');
|
|
14
|
+
req.__rscClientManifest = context.get('rscClientManifest');
|
|
15
|
+
req.__rscSSRManifest = context.get('rscSSRManifest');
|
|
16
|
+
try {
|
|
17
|
+
await handler(req, res);
|
|
18
|
+
} finally{
|
|
19
|
+
delete req.__honoRequest;
|
|
20
|
+
delete req.__templates;
|
|
21
|
+
delete req.__serverManifest;
|
|
22
|
+
delete req.__rscServerManifest;
|
|
23
|
+
delete req.__rscClientManifest;
|
|
24
|
+
delete req.__rscSSRManifest;
|
|
25
|
+
res.removeListener?.('pipe', onPipe);
|
|
26
|
+
}
|
|
27
|
+
if (isResFinalized(res)) {
|
|
28
|
+
context.res;
|
|
29
|
+
context.finalized = true;
|
|
30
|
+
} else await next();
|
|
31
|
+
};
|
|
32
|
+
const noop = ()=>{};
|
|
33
|
+
const connectMid2HonoMid = (handler)=>async (context, next)=>new Promise((resolve, reject)=>{
|
|
34
|
+
const { req, res } = context.env.node;
|
|
35
|
+
if (handler.length < 3) resolve(handler(req, res, noop));
|
|
36
|
+
else handler(req, res, (err)=>{
|
|
37
|
+
if (err) reject(err);
|
|
38
|
+
else resolve(next());
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const connectMockMid2HonoMid = (handler)=>async (context, next)=>new Promise((resolve, reject)=>{
|
|
42
|
+
const { req, res: rawRes } = context.env.node;
|
|
43
|
+
const res = rawRes;
|
|
44
|
+
if (handler.length < 3) {
|
|
45
|
+
res.once?.('finish', ()=>{
|
|
46
|
+
context.res;
|
|
47
|
+
context.finalized = true;
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
handler(req, res, noop);
|
|
51
|
+
} else handler(req, res, (err)=>{
|
|
52
|
+
if (err) reject(err);
|
|
53
|
+
else resolve(next());
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
export { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig } from "./helper/index.mjs";
|
|
3
|
+
export { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid } from "./hono.mjs";
|
|
4
|
+
export { createNodeServer, createWebRequest, sendResponse } from "./node.mjs";
|
|
5
|
+
export { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin } from "./plugins/index.mjs";
|