@ecopages/core 0.2.0-rc.0 → 0.2.0-rc.10
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/README.md +52 -33
- package/package.json +58 -4
- package/src/adapters/README.md +3 -1
- package/src/adapters/abstract/application-adapter.d.ts +28 -6
- package/src/adapters/abstract/application-adapter.js +58 -5
- package/src/adapters/abstract/segment-path-matcher.js +56 -38
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- package/src/adapters/bun/create-app.d.ts +10 -6
- package/src/adapters/bun/create-app.js +64 -37
- package/src/adapters/bun/server-adapter.d.ts +6 -2
- package/src/adapters/bun/server-adapter.js +14 -1
- package/src/adapters/create-app.d.ts +62 -7
- package/src/adapters/create-app.js +61 -5
- package/src/adapters/node/create-app.d.ts +5 -5
- package/src/adapters/node/create-app.js +18 -5
- package/src/adapters/node/runtime-host.js +9 -4
- package/src/adapters/node/server-adapter.d.ts +5 -1
- package/src/adapters/node/server-adapter.js +16 -1
- package/src/adapters/shared/http/define-api-handler.d.ts +7 -49
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- package/src/adapters/shared/runtime/server-adapter.d.ts +14 -5
- package/src/adapters/shared/runtime/server-adapter.js +22 -30
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- package/src/build/README.md +5 -1
- package/src/build/cache/server-entry-build-cache.d.ts +24 -1
- package/src/build/cache/server-entry-build-cache.js +125 -8
- package/src/build/contracts/content-virtual-modules.d.ts +3 -1
- package/src/build/contracts/content-virtual-modules.js +8 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +56 -31
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -29
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +6 -0
- package/src/config/apply-user-config.js +67 -0
- package/src/config/config-builder.d.ts +10 -1
- package/src/config/config-builder.js +51 -10
- package/src/config/constants.d.ts +4 -0
- package/src/config/constants.js +4 -0
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +100 -0
- package/src/config/resolve-eco-config-path.d.ts +23 -0
- package/src/config/resolve-eco-config-path.js +47 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +164 -0
- package/src/config/user-config-types.js +1 -0
- package/src/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +11 -5
- package/src/dev/README.md +6 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
- package/src/dev/transform-server/dev-transform-server.js +16 -5
- package/src/eco/README.md +73 -5
- package/src/eco/component-identity.d.ts +3 -2
- package/src/eco/component-identity.js +5 -2
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco.js +6 -0
- package/src/eco/eco.types.d.ts +18 -2
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +3 -0
- package/src/index.d.ts +4 -1
- package/src/index.js +4 -1
- package/src/islands/README.md +5 -1
- package/src/plugins/README.md +10 -2
- package/src/plugins/component-import-discovery.d.ts +19 -0
- package/src/plugins/component-import-discovery.js +241 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
- package/src/plugins/eco-component-meta-plugin.js +118 -16
- package/src/plugins/integration-plugin.d.ts +4 -9
- package/src/plugins/processor.d.ts +23 -2
- package/src/plugins/processor.js +25 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/route-renderer/GRAPH.md +1 -1
- package/src/route-renderer/README.md +16 -3
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +2 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +13 -1
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +15 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
- package/src/route-renderer/orchestration/integration-renderer.d.ts +11 -5
- package/src/route-renderer/orchestration/integration-renderer.js +42 -29
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +10 -8
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
- package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +5 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +44 -0
- package/src/services/error-pages/default-error-pages.js +207 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +7 -1
- package/src/services/invalidation/development-invalidation.service.js +35 -3
- package/src/services/module-loading/README.md +16 -13
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
- package/src/services/module-loading/collection-server-module-build.service.js +5 -2
- package/src/services/module-loading/page-module-import.service.d.ts +8 -0
- package/src/services/module-loading/page-module-import.service.js +62 -28
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- package/src/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/README.md +6 -1
- package/src/static-site-generator/static-site-generator.d.ts +7 -2
- package/src/static-site-generator/static-site-generator.js +90 -49
- package/src/types/internal-types.d.ts +6 -1
- package/src/types/public-types.d.ts +34 -24
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -1
- package/src/watchers/project-watcher.js +85 -34
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Server as NodeHttpServer } from 'node:http';
|
|
2
2
|
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
3
|
-
import type { ApiHandler, ErrorHandler, StaticRoute, EcopagesWebSocketHandler } from '../../types/public-types.js';
|
|
3
|
+
import type { ApiHandler, ErrorHandler, StaticRoute, ErrorPageLoaders, EcopagesWebSocketHandler } from '../../types/public-types.js';
|
|
4
4
|
import { SharedServerAdapter } from '../shared/runtime/server-adapter.js';
|
|
5
5
|
import type { ServerAdapterResult } from '../abstract/server-adapter.js';
|
|
6
6
|
import { NodeHttpRequestBridge } from './http-request-bridge.js';
|
|
@@ -18,6 +18,7 @@ export interface NodeServerAdapterParams {
|
|
|
18
18
|
serveOptions: NodeServeAdapterServerOptions;
|
|
19
19
|
apiHandlers?: ApiHandler[];
|
|
20
20
|
staticRoutes?: StaticRoute[];
|
|
21
|
+
errorPageLoaders?: ErrorPageLoaders;
|
|
21
22
|
errorHandler?: ErrorHandler;
|
|
22
23
|
websocketHandlers?: Map<string, EcopagesWebSocketHandler<any, any>>;
|
|
23
24
|
hostOwnsDevClient?: boolean;
|
|
@@ -26,6 +27,7 @@ export interface NodeServerAdapterParams {
|
|
|
26
27
|
};
|
|
27
28
|
deferRuntimeAssetSetup?: boolean;
|
|
28
29
|
allowPortFallback?: boolean;
|
|
30
|
+
onDevelopmentRestart?: (changedFile: string) => Promise<void>;
|
|
29
31
|
previewHost?: StaticPreviewHost;
|
|
30
32
|
requestBridge?: NodeHttpRequestBridge;
|
|
31
33
|
devRuntimeFactory?: NodeServerDevRuntimeFactory;
|
|
@@ -63,6 +65,7 @@ export declare class NodeServerAdapter extends SharedServerAdapter<NodeServerAda
|
|
|
63
65
|
private initialized;
|
|
64
66
|
private apiHandlers;
|
|
65
67
|
private staticRoutes;
|
|
68
|
+
private errorPageLoaders;
|
|
66
69
|
private errorHandler?;
|
|
67
70
|
private bridge;
|
|
68
71
|
private hmrManager;
|
|
@@ -70,6 +73,7 @@ export declare class NodeServerAdapter extends SharedServerAdapter<NodeServerAda
|
|
|
70
73
|
private adapterDisposed;
|
|
71
74
|
private readonly deferRuntimeAssetSetup;
|
|
72
75
|
private readonly allowPortFallback;
|
|
76
|
+
private readonly onDevelopmentRestart?;
|
|
73
77
|
private readonly previewHost;
|
|
74
78
|
private readonly requestBridge;
|
|
75
79
|
private readonly devRuntimeFactory;
|
|
@@ -4,6 +4,7 @@ import { fileSystem } from '@ecopages/file-system';
|
|
|
4
4
|
import { setupAppRuntimePlugins } from '../../build/build-adapter.js';
|
|
5
5
|
import { installBuildRuntime } from '../../build/runtime/build-runtime.js';
|
|
6
6
|
import { appLogger } from '../../global/app-logger.js';
|
|
7
|
+
import { entryWatcherOwnsConfig } from '../../dev/development-restart.js';
|
|
7
8
|
import { NodeClientBridge } from './node-client-bridge.js';
|
|
8
9
|
import { NodeHmrManager } from './node-hmr-manager.js';
|
|
9
10
|
import { ProjectWatcher } from '../../watchers/project-watcher.js';
|
|
@@ -42,6 +43,7 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
42
43
|
initialized = false;
|
|
43
44
|
apiHandlers;
|
|
44
45
|
staticRoutes;
|
|
46
|
+
errorPageLoaders;
|
|
45
47
|
errorHandler;
|
|
46
48
|
bridge = null;
|
|
47
49
|
hmrManager = null;
|
|
@@ -49,6 +51,7 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
49
51
|
adapterDisposed = false;
|
|
50
52
|
deferRuntimeAssetSetup;
|
|
51
53
|
allowPortFallback;
|
|
54
|
+
onDevelopmentRestart;
|
|
52
55
|
previewHost;
|
|
53
56
|
requestBridge;
|
|
54
57
|
devRuntimeFactory;
|
|
@@ -95,8 +98,10 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
95
98
|
super(options);
|
|
96
99
|
this.deferRuntimeAssetSetup = options.deferRuntimeAssetSetup === true;
|
|
97
100
|
this.allowPortFallback = options.allowPortFallback !== false;
|
|
101
|
+
this.onDevelopmentRestart = options.onDevelopmentRestart;
|
|
98
102
|
this.apiHandlers = options.apiHandlers || [];
|
|
99
103
|
this.staticRoutes = options.staticRoutes || [];
|
|
104
|
+
this.errorPageLoaders = options.errorPageLoaders ?? {};
|
|
100
105
|
this.errorHandler = options.errorHandler;
|
|
101
106
|
this.previewHost = options.previewHost;
|
|
102
107
|
this.requestBridge = options.requestBridge;
|
|
@@ -130,6 +135,7 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
130
135
|
}
|
|
131
136
|
await this.initializeSharedRouteHandling({
|
|
132
137
|
staticRoutes: this.staticRoutes,
|
|
138
|
+
errorPageLoaders: this.errorPageLoaders,
|
|
133
139
|
hmrManager: this.hmrManager ?? undefined,
|
|
134
140
|
});
|
|
135
141
|
this.staticSiteGenerator = new StaticSiteGenerator({ appConfig: this.appConfig });
|
|
@@ -157,6 +163,7 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
157
163
|
router: this.router,
|
|
158
164
|
routeRendererFactory: this.routeRendererFactory,
|
|
159
165
|
staticRoutes: this.staticRoutes,
|
|
166
|
+
errorPageLoaders: this.errorPageLoaders,
|
|
160
167
|
});
|
|
161
168
|
if (!options?.preview) {
|
|
162
169
|
return undefined;
|
|
@@ -199,6 +206,7 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
199
206
|
completeInitialization: this.completeInitialization.bind(this),
|
|
200
207
|
handleRequest: this.handleRequest.bind(this),
|
|
201
208
|
attachUserWebSocketUpgrades: this.attachUserWebSocketUpgrades.bind(this),
|
|
209
|
+
applyBoundPort: this.applyBoundPort.bind(this),
|
|
202
210
|
listStaticGenerationRoutes: (input) => this.router.listStaticGenerationRoutes(input),
|
|
203
211
|
dispose: this.dispose.bind(this),
|
|
204
212
|
};
|
|
@@ -313,17 +321,24 @@ export class NodeServerAdapter extends SharedServerAdapter {
|
|
|
313
321
|
appConfig: this.appConfig,
|
|
314
322
|
runtimeOrigin: this.runtimeOrigin,
|
|
315
323
|
});
|
|
316
|
-
this.configureSharedResponseHandlers(
|
|
324
|
+
this.configureSharedResponseHandlers({
|
|
325
|
+
staticRoutes: this.staticRoutes,
|
|
326
|
+
hmrManager: this.hmrManager,
|
|
327
|
+
errorPageLoaders: this.errorPageLoaders,
|
|
328
|
+
});
|
|
317
329
|
await this.startDevStaticRoutePrewarmWhenReady();
|
|
318
330
|
const watcher = new ProjectWatcher({
|
|
319
331
|
config: this.appConfig,
|
|
320
332
|
refreshRouterRoutesCallback: this.createSharedWatchRefreshCallback({
|
|
321
333
|
staticRoutes: this.staticRoutes,
|
|
334
|
+
errorPageLoaders: this.errorPageLoaders,
|
|
322
335
|
hmrManager: this.hmrManager ?? undefined,
|
|
323
336
|
}),
|
|
324
337
|
hmrManager: this.hmrManager ?? undefined,
|
|
325
338
|
bridge: this.bridge,
|
|
326
339
|
hostOwnsDevClient: this.hostOwnsDevClient,
|
|
340
|
+
onRestartRequest: this.onDevelopmentRestart,
|
|
341
|
+
entryWatcherOwnsConfig: entryWatcherOwnsConfig(),
|
|
327
342
|
});
|
|
328
343
|
this.projectWatcher = watcher;
|
|
329
344
|
await watcher.createWatcherSubscription();
|
|
@@ -12,55 +12,13 @@ export declare function defineApiHandler<TPath extends string, TSchema extends R
|
|
|
12
12
|
declare const defineApiMethod: <M extends ApiHandler["method"]>(method: M) => <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: DefineApiHandlerInput<TPath, TSchema, TContext> & {
|
|
13
13
|
path: TPath;
|
|
14
14
|
}) => ApiHandler<TPath, Request, unknown>;
|
|
15
|
-
export declare const defineGet: <
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare const definePost: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
23
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
24
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
25
|
-
schema?: TSchema | undefined;
|
|
26
|
-
} & {
|
|
27
|
-
path: TPath;
|
|
28
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
29
|
-
export declare const definePut: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
30
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
31
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
32
|
-
schema?: TSchema | undefined;
|
|
33
|
-
} & {
|
|
34
|
-
path: TPath;
|
|
35
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
36
|
-
export declare const defineDelete: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
37
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
38
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
39
|
-
schema?: TSchema | undefined;
|
|
40
|
-
} & {
|
|
41
|
-
path: TPath;
|
|
42
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
43
|
-
export declare const definePatch: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
44
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
45
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
46
|
-
schema?: TSchema | undefined;
|
|
47
|
-
} & {
|
|
48
|
-
path: TPath;
|
|
49
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
50
|
-
export declare const defineOptions: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
51
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
52
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
53
|
-
schema?: TSchema | undefined;
|
|
54
|
-
} & {
|
|
55
|
-
path: TPath;
|
|
56
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
57
|
-
export declare const defineHead: <const TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, "middleware" | "method" | "schema" | "handler"> & {
|
|
58
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
59
|
-
middleware?: Middleware<Request, unknown, TContext>[] | undefined;
|
|
60
|
-
schema?: TSchema | undefined;
|
|
61
|
-
} & {
|
|
62
|
-
path: TPath;
|
|
63
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
15
|
+
export declare const defineGet: ReturnType<typeof defineApiMethod<'GET'>>;
|
|
16
|
+
export declare const definePost: ReturnType<typeof defineApiMethod<'POST'>>;
|
|
17
|
+
export declare const definePut: ReturnType<typeof defineApiMethod<'PUT'>>;
|
|
18
|
+
export declare const defineDelete: ReturnType<typeof defineApiMethod<'DELETE'>>;
|
|
19
|
+
export declare const definePatch: ReturnType<typeof defineApiMethod<'PATCH'>>;
|
|
20
|
+
export declare const defineOptions: ReturnType<typeof defineApiMethod<'OPTIONS'>>;
|
|
21
|
+
export declare const defineHead: ReturnType<typeof defineApiMethod<'HEAD'>>;
|
|
64
22
|
export declare function json(data: unknown, options?: ResponseOptions): Response;
|
|
65
23
|
export declare function html(content: string, options?: ResponseOptions): Response;
|
|
66
24
|
export declare function redirect(url: string, status?: number): Response;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { appLogger } from '../../../global/app-logger.js';
|
|
2
|
-
import {
|
|
2
|
+
import { shouldLogPageFailure } from '../../../errors/http-error-page-contract.js';
|
|
3
|
+
import { prepareExplicitStaticRender } from '../../../route-renderer/explicit-view-render-preparation.js';
|
|
3
4
|
import { matchExplicitStaticPathPattern } from '../../abstract/segment-path-matcher.js';
|
|
4
5
|
export const EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS = {
|
|
5
6
|
missingIntegration: (routePath) => `View at ${routePath} is missing component identity integration. Ensure it's defined with eco.page() and exported as default.`,
|
|
@@ -52,7 +53,9 @@ export class ExplicitStaticRouteMatcher {
|
|
|
52
53
|
return renderer.renderToResponse(renderableView, props, {});
|
|
53
54
|
}
|
|
54
55
|
catch (error) {
|
|
55
|
-
|
|
56
|
+
if (shouldLogPageFailure(error)) {
|
|
57
|
+
appLogger.error(`Error rendering explicit static route ${route.path}:`, error instanceof Error ? error : String(error));
|
|
58
|
+
}
|
|
56
59
|
throw error;
|
|
57
60
|
}
|
|
58
61
|
}
|
|
@@ -11,16 +11,10 @@ export declare class FileSystemServerResponseFactory {
|
|
|
11
11
|
isHtml(contentType: string): contentType is "text/html";
|
|
12
12
|
shouldEnableGzip(contentType: string): boolean;
|
|
13
13
|
createResponseWithBody(body: RouteRendererBody, init?: ResponseInit): Promise<Response>;
|
|
14
|
-
createDefaultNotFoundResponse(): Promise<Response>;
|
|
15
14
|
/**
|
|
16
|
-
* Wraps already-rendered HTML in
|
|
15
|
+
* Wraps already-rendered HTML in an error response envelope.
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
|
-
createDefaultServerErrorResponse(): Promise<Response>;
|
|
20
|
-
/**
|
|
21
|
-
* Wraps already-rendered HTML in a 500 response envelope.
|
|
22
|
-
*/
|
|
23
|
-
createHtmlServerErrorResponse(body: RouteRendererBody): Promise<Response>;
|
|
17
|
+
createHtmlErrorResponse(status: number, body: RouteRendererBody): Promise<Response>;
|
|
24
18
|
/**
|
|
25
19
|
* Reads a static file response, returning `null` when the file is missing.
|
|
26
20
|
*/
|
|
@@ -25,40 +25,15 @@ export class FileSystemServerResponseFactory {
|
|
|
25
25
|
}) {
|
|
26
26
|
return new Response(body, init);
|
|
27
27
|
}
|
|
28
|
-
async createDefaultNotFoundResponse() {
|
|
29
|
-
return new Response(STATUS_MESSAGE[404], {
|
|
30
|
-
status: 404,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Wraps already-rendered HTML in a 404 response envelope.
|
|
35
|
-
*/
|
|
36
|
-
async createHtmlNotFoundResponse(body) {
|
|
37
|
-
return await this.createResponseWithBody(body, {
|
|
38
|
-
status: 404,
|
|
39
|
-
statusText: STATUS_MESSAGE[404],
|
|
40
|
-
headers: {
|
|
41
|
-
'Content-Type': 'text/html',
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
async createDefaultServerErrorResponse() {
|
|
46
|
-
return new Response(STATUS_MESSAGE[500], {
|
|
47
|
-
status: 500,
|
|
48
|
-
headers: {
|
|
49
|
-
'Content-Type': 'text/plain; charset=utf-8',
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
28
|
/**
|
|
54
|
-
* Wraps already-rendered HTML in
|
|
29
|
+
* Wraps already-rendered HTML in an error response envelope.
|
|
55
30
|
*/
|
|
56
|
-
async
|
|
31
|
+
async createHtmlErrorResponse(status, body) {
|
|
57
32
|
return await this.createResponseWithBody(body, {
|
|
58
|
-
status
|
|
59
|
-
statusText: STATUS_MESSAGE[
|
|
33
|
+
status,
|
|
34
|
+
statusText: STATUS_MESSAGE[status] ?? String(status),
|
|
60
35
|
headers: {
|
|
61
|
-
'Content-Type': 'text/html',
|
|
36
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
62
37
|
},
|
|
63
38
|
});
|
|
64
39
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { EcoPagesAppConfig, MatchResult } from '../../../types/internal-types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StaticGenerationRendererResolver } from '../../../route-renderer/route-renderer.js';
|
|
3
3
|
import type { RouteRegistry } from '../../../router/server/route-registry.js';
|
|
4
4
|
import type { PageCacheService } from '../../../services/cache/page-cache-service.js';
|
|
5
5
|
import type { CacheStrategy } from '../../../services/cache/cache.types.js';
|
|
6
6
|
import type { FileSystemServerResponseFactory } from './fs-server-response-factory.js';
|
|
7
|
+
import type { ErrorPageLoaders } from '../../../types/public-types.js';
|
|
7
8
|
export interface FileSystemResponseMatcherOptions {
|
|
8
9
|
appConfig: EcoPagesAppConfig;
|
|
9
10
|
assetPrefix: string;
|
|
10
11
|
router: RouteRegistry;
|
|
11
|
-
routeRendererFactory:
|
|
12
|
+
routeRendererFactory: StaticGenerationRendererResolver;
|
|
13
|
+
errorPageLoaders?: ErrorPageLoaders;
|
|
12
14
|
fileSystemResponseFactory: FileSystemServerResponseFactory;
|
|
13
15
|
/** Optional cache service. When null, caching is disabled. */
|
|
14
16
|
cacheService?: PageCacheService | null;
|
|
@@ -27,10 +29,11 @@ export declare class FileSystemResponseMatcher {
|
|
|
27
29
|
private assetPrefix;
|
|
28
30
|
private router;
|
|
29
31
|
private routeRendererFactory;
|
|
32
|
+
private errorPageRenderer;
|
|
30
33
|
private fileSystemResponseFactory;
|
|
31
34
|
private pageRequestCacheCoordinator;
|
|
32
35
|
private fileRouteMiddlewarePipeline;
|
|
33
|
-
constructor({ appConfig, assetPrefix, router, routeRendererFactory, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
|
|
36
|
+
constructor({ appConfig, assetPrefix, router, routeRendererFactory, errorPageLoaders, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
|
|
34
37
|
/**
|
|
35
38
|
* Resolves unmatched paths either as static asset requests or as the custom
|
|
36
39
|
* not-found page.
|
|
@@ -51,30 +54,27 @@ export declare class FileSystemResponseMatcher {
|
|
|
51
54
|
*/
|
|
52
55
|
handleMatch(match: MatchResult, request?: Request): Promise<Response>;
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
* when the page template cannot be resolved.
|
|
61
|
-
*/
|
|
62
|
-
private renderCustomServerErrorResponse;
|
|
63
|
-
/**
|
|
64
|
-
* Builds development-only error details for the custom 500 page.
|
|
65
|
-
* @remarks Production omits these fields so stacks are not serialized into HTML.
|
|
57
|
+
* Translates a page-pipeline failure into an HTML response whose status matches
|
|
58
|
+
* the thrown `HttpError`, or 500 for generic failures.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Explicit static routes and filesystem pages share this so client `HttpError`
|
|
62
|
+
* statuses cannot be collapsed into a server error.
|
|
66
63
|
*/
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
private
|
|
64
|
+
renderServerError(pathname: string, error: unknown): Promise<Response>;
|
|
65
|
+
private renderPageFailure;
|
|
66
|
+
private renderClientErrorResponseOrServerError;
|
|
67
|
+
private renderErrorResponse;
|
|
70
68
|
/**
|
|
71
|
-
* Logs
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
69
|
+
* Logs a server failure, then renders the server-error page with the classified status.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Non-factory 5xx statuses reuse the server-error page without being rewritten to 500.
|
|
73
|
+
* A failure while rendering that page falls back to the built-in document at the same
|
|
74
|
+
* status and never re-enters the custom page path. In development the thrown error's
|
|
75
|
+
* `message` and `stack` are passed into the page props.
|
|
76
76
|
*/
|
|
77
|
-
private
|
|
77
|
+
private createServerErrorResponse;
|
|
78
78
|
private createExecutionPlan;
|
|
79
79
|
/**
|
|
80
80
|
* Loads the matched page module for request-time inspection.
|
|
@@ -4,9 +4,9 @@ import { PageRequestCacheCoordinator } from '../../../services/cache/page-reques
|
|
|
4
4
|
import { getBrowserRuntimeAssetGeneration } from '../../../services/assets/browser-runtime-asset-generation.js';
|
|
5
5
|
import { ServerUtils } from '../../../utils/server-utils.module.js';
|
|
6
6
|
import { FileRouteMiddlewarePipeline } from './file-route-middleware-pipeline.js';
|
|
7
|
-
import {
|
|
8
|
-
import { LocalsAccessError } from '../../../errors/locals-access-error.js';
|
|
7
|
+
import { classifyPageFailure } from '../../../errors/http-error-page-contract.js';
|
|
9
8
|
import { isDevelopmentRuntime } from '../../../utils/runtime.js';
|
|
9
|
+
import { ErrorPageRenderer, logErrorPageFailure } from '../../../services/error-pages/error-page-renderer.js';
|
|
10
10
|
/**
|
|
11
11
|
* Matches file-system routes to rendered HTML responses.
|
|
12
12
|
*
|
|
@@ -19,14 +19,20 @@ export class FileSystemResponseMatcher {
|
|
|
19
19
|
assetPrefix;
|
|
20
20
|
router;
|
|
21
21
|
routeRendererFactory;
|
|
22
|
+
errorPageRenderer;
|
|
22
23
|
fileSystemResponseFactory;
|
|
23
24
|
pageRequestCacheCoordinator;
|
|
24
25
|
fileRouteMiddlewarePipeline;
|
|
25
|
-
constructor({ appConfig, assetPrefix, router, routeRendererFactory, fileSystemResponseFactory, cacheService = null, defaultCacheStrategy = 'static', }) {
|
|
26
|
+
constructor({ appConfig, assetPrefix, router, routeRendererFactory, errorPageLoaders = {}, fileSystemResponseFactory, cacheService = null, defaultCacheStrategy = 'static', }) {
|
|
26
27
|
this.appConfig = appConfig;
|
|
27
28
|
this.assetPrefix = assetPrefix;
|
|
28
29
|
this.router = router;
|
|
29
30
|
this.routeRendererFactory = routeRendererFactory;
|
|
31
|
+
this.errorPageRenderer = new ErrorPageRenderer({
|
|
32
|
+
appConfig,
|
|
33
|
+
routeRendererFactory,
|
|
34
|
+
errorPageLoaders,
|
|
35
|
+
});
|
|
30
36
|
this.fileSystemResponseFactory = fileSystemResponseFactory;
|
|
31
37
|
this.pageRequestCacheCoordinator = new PageRequestCacheCoordinator(cacheService, defaultCacheStrategy, () => getBrowserRuntimeAssetGeneration(this.appConfig));
|
|
32
38
|
this.fileRouteMiddlewarePipeline = new FileRouteMiddlewarePipeline(cacheService);
|
|
@@ -40,13 +46,14 @@ export class FileSystemResponseMatcher {
|
|
|
40
46
|
async handleNoMatch(requestUrl) {
|
|
41
47
|
const isStaticFileRequest = ServerUtils.hasKnownStaticExtension(requestUrl);
|
|
42
48
|
if (!isStaticFileRequest) {
|
|
43
|
-
return this.
|
|
49
|
+
return this.renderClientErrorResponseOrServerError(requestUrl, { status: 404, kind: 'notFound', logAsServerError: false }, undefined);
|
|
44
50
|
}
|
|
45
51
|
const relativeUrl = requestUrl.startsWith('/') ? requestUrl.slice(1) : requestUrl;
|
|
46
52
|
const filePath = path.join(this.assetPrefix, relativeUrl);
|
|
47
53
|
const contentType = ServerUtils.getContentType(filePath);
|
|
48
54
|
const response = await this.fileSystemResponseFactory.createFileResponse(filePath, contentType);
|
|
49
|
-
return response ??
|
|
55
|
+
return (response ??
|
|
56
|
+
this.renderClientErrorResponseOrServerError(requestUrl, { status: 404, kind: 'notFound', logAsServerError: false }, undefined));
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* Handles a matched file-system page route.
|
|
@@ -103,96 +110,60 @@ export class FileSystemResponseMatcher {
|
|
|
103
110
|
});
|
|
104
111
|
}
|
|
105
112
|
catch (error) {
|
|
106
|
-
|
|
107
|
-
return error;
|
|
108
|
-
}
|
|
109
|
-
if (HttpError.isHttpError(error) && error.status === 404) {
|
|
110
|
-
return await this.renderCustomNotFoundResponseOrServerError(match.requestedPathname);
|
|
111
|
-
}
|
|
112
|
-
if (error instanceof LocalsAccessError) {
|
|
113
|
-
return await this.createInternalServerErrorResponse(error.message, match.requestedPathname, error);
|
|
114
|
-
}
|
|
115
|
-
return await this.createInternalServerErrorResponse(error instanceof Error ? error.message : 'Internal Server Error', match.requestedPathname, error);
|
|
113
|
+
return await this.renderPageFailure(match.requestedPathname, error);
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
label: '404',
|
|
126
|
-
createDefaultResponse: () => this.fileSystemResponseFactory.createDefaultNotFoundResponse(),
|
|
127
|
-
createHtmlResponse: (body) => this.fileSystemResponseFactory.createHtmlNotFoundResponse(body),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Renders the app-owned custom 500 page, falling back to the default text 500
|
|
132
|
-
* when the page template cannot be resolved.
|
|
117
|
+
* Translates a page-pipeline failure into an HTML response whose status matches
|
|
118
|
+
* the thrown `HttpError`, or 500 for generic failures.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Explicit static routes and filesystem pages share this so client `HttpError`
|
|
122
|
+
* statuses cannot be collapsed into a server error.
|
|
133
123
|
*/
|
|
134
|
-
async
|
|
135
|
-
return this.
|
|
136
|
-
templatePath: this.appConfig.absolutePaths.error500TemplatePath,
|
|
137
|
-
label: '500',
|
|
138
|
-
props: this.buildServerErrorPageProps(error),
|
|
139
|
-
createDefaultResponse: () => this.fileSystemResponseFactory.createDefaultServerErrorResponse(),
|
|
140
|
-
createHtmlResponse: (body) => this.fileSystemResponseFactory.createHtmlServerErrorResponse(body),
|
|
141
|
-
});
|
|
124
|
+
async renderServerError(pathname, error) {
|
|
125
|
+
return this.renderPageFailure(pathname, error);
|
|
142
126
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
*/
|
|
147
|
-
buildServerErrorPageProps(error) {
|
|
148
|
-
if (!isDevelopmentRuntime()) {
|
|
149
|
-
return undefined;
|
|
127
|
+
async renderPageFailure(pathname, error) {
|
|
128
|
+
if (error instanceof Response) {
|
|
129
|
+
return error;
|
|
150
130
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
stack: error.stack,
|
|
155
|
-
};
|
|
131
|
+
const classification = classifyPageFailure(error);
|
|
132
|
+
if (classification.status >= 500) {
|
|
133
|
+
return await this.createServerErrorResponse(pathname, classification, error);
|
|
156
134
|
}
|
|
157
|
-
return
|
|
158
|
-
message: String(error),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
async renderCustomErrorPageResponse({ templatePath, label, props, createDefaultResponse, createHtmlResponse, }) {
|
|
162
|
-
let routeRenderer;
|
|
163
|
-
try {
|
|
164
|
-
routeRenderer = this.routeRendererFactory.getPageRenderer(templatePath);
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
appLogger.debug(`Custom ${label} template not found, falling back to default ${label} response`, templatePath);
|
|
168
|
-
return createDefaultResponse();
|
|
169
|
-
}
|
|
170
|
-
const result = await routeRenderer.execute({
|
|
171
|
-
file: templatePath,
|
|
172
|
-
props,
|
|
173
|
-
locals: {},
|
|
174
|
-
});
|
|
175
|
-
return createHtmlResponse(result.body);
|
|
135
|
+
return await this.renderClientErrorResponseOrServerError(pathname, classification, error);
|
|
176
136
|
}
|
|
177
|
-
async
|
|
137
|
+
async renderClientErrorResponseOrServerError(pathname, classification, error) {
|
|
178
138
|
try {
|
|
179
|
-
return await this.
|
|
139
|
+
return await this.renderErrorResponse(classification, error);
|
|
180
140
|
}
|
|
181
|
-
catch (
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
141
|
+
catch (pageError) {
|
|
142
|
+
if (pageError instanceof Response) {
|
|
143
|
+
return pageError;
|
|
184
144
|
}
|
|
185
|
-
return await this.
|
|
145
|
+
return await this.createServerErrorResponse(pathname, { status: 500, kind: 'serverError', logAsServerError: true }, pageError);
|
|
186
146
|
}
|
|
187
147
|
}
|
|
148
|
+
async renderErrorResponse(classification, error) {
|
|
149
|
+
const result = await this.errorPageRenderer.render({
|
|
150
|
+
kind: classification.kind,
|
|
151
|
+
status: classification.status,
|
|
152
|
+
error,
|
|
153
|
+
});
|
|
154
|
+
return await this.fileSystemResponseFactory.createHtmlErrorResponse(classification.status, result.body);
|
|
155
|
+
}
|
|
188
156
|
/**
|
|
189
|
-
* Logs
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
157
|
+
* Logs a server failure, then renders the server-error page with the classified status.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Non-factory 5xx statuses reuse the server-error page without being rewritten to 500.
|
|
161
|
+
* A failure while rendering that page falls back to the built-in document at the same
|
|
162
|
+
* status and never re-enters the custom page path. In development the thrown error's
|
|
163
|
+
* `message` and `stack` are passed into the page props.
|
|
194
164
|
*/
|
|
195
|
-
async
|
|
165
|
+
async createServerErrorResponse(pathname, classification, error) {
|
|
166
|
+
const message = error instanceof Error ? error.message : 'Internal Server Error';
|
|
196
167
|
if (isDevelopmentRuntime() || appLogger.isDebugEnabled()) {
|
|
197
168
|
appLogger.error(`[FileSystemResponseMatcher] ${message} at ${pathname}`, error);
|
|
198
169
|
}
|
|
@@ -200,14 +171,19 @@ export class FileSystemResponseMatcher {
|
|
|
200
171
|
appLogger.error(`[FileSystemResponseMatcher] Render error at ${pathname}`, error);
|
|
201
172
|
}
|
|
202
173
|
try {
|
|
203
|
-
return await this.
|
|
174
|
+
return await this.renderErrorResponse(classification, error);
|
|
204
175
|
}
|
|
205
176
|
catch (serverErrorPageError) {
|
|
206
177
|
if (serverErrorPageError instanceof Response) {
|
|
207
178
|
return serverErrorPageError;
|
|
208
179
|
}
|
|
209
|
-
|
|
210
|
-
|
|
180
|
+
logErrorPageFailure(classification.kind ?? 'serverError', serverErrorPageError);
|
|
181
|
+
const result = this.errorPageRenderer.renderBuiltIn({
|
|
182
|
+
kind: classification.kind ?? 'serverError',
|
|
183
|
+
status: classification.status,
|
|
184
|
+
error,
|
|
185
|
+
});
|
|
186
|
+
return this.fileSystemResponseFactory.createHtmlErrorResponse(classification.status, result.body);
|
|
211
187
|
}
|
|
212
188
|
}
|
|
213
189
|
async createExecutionPlan(match, request) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AbstractApplicationAdapter, } from '../../abstract/application-adapter.js';
|
|
2
|
+
import { ECOPAGES_DEV_RESTART_EXIT_CODE } from '../../../dev/development-restart.js';
|
|
3
|
+
import { appLogger } from '../../../global/app-logger.js';
|
|
2
4
|
export class SharedApplicationAdapter extends AbstractApplicationAdapter {
|
|
3
5
|
register(path, method, handler, options) {
|
|
4
6
|
return this.addRouteHandler(path, method, handler, options?.middleware, options?.schema);
|
|
@@ -72,4 +74,14 @@ export class SharedApplicationAdapter extends AbstractApplicationAdapter {
|
|
|
72
74
|
}
|
|
73
75
|
return this;
|
|
74
76
|
}
|
|
77
|
+
createDevelopmentRestartHandler() {
|
|
78
|
+
if (this.runtimeOptions.embedded) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return async (changedFile) => {
|
|
82
|
+
appLogger.info(`Configuration or environment file changed (${changedFile}). Restarting development server...`);
|
|
83
|
+
await this.stop();
|
|
84
|
+
process.exit(ECOPAGES_DEV_RESTART_EXIT_CODE);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
75
87
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RuntimeHost, RuntimeHostStartOptions } from './runtime-host.js';
|
|
2
|
+
/**
|
|
3
|
+
* Starts a runtime server, optionally negotiating a fallback port via
|
|
4
|
+
* {@link PortManager}.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bindRuntimeServer<TServer, TServeOptions extends {
|
|
7
|
+
port?: number | string;
|
|
8
|
+
hostname?: string;
|
|
9
|
+
}>(runtimeHost: RuntimeHost<TServer, TServeOptions>, options: {
|
|
10
|
+
startOptions: RuntimeHostStartOptions<TServeOptions>;
|
|
11
|
+
allowPortFallback: boolean;
|
|
12
|
+
usePortManager: boolean;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
server: TServer;
|
|
15
|
+
port: number;
|
|
16
|
+
runtimeOrigin: string;
|
|
17
|
+
}>;
|