@jay-framework/jay-fetch-handler 0.1.1 → 0.2.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/dist/index.d.ts +14 -1
- package/dist/index.js +14 -5
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { type ArtifactStore, type PreImportedPlugin } from '@jay-framework/production-server';
|
|
3
|
+
export type { ArtifactStore } from '@jay-framework/production-server';
|
|
4
|
+
export type { PreImportedPlugin } from '@jay-framework/production-server';
|
|
2
5
|
export interface JayFetchHandlerOptions {
|
|
3
|
-
|
|
6
|
+
/** Filesystem path to backend build output (creates FilesystemArtifactStore) */
|
|
7
|
+
backendDir?: string;
|
|
8
|
+
/** Custom artifact store for non-filesystem backends (DL#143) */
|
|
9
|
+
artifactStore?: ArtifactStore;
|
|
4
10
|
staticBaseUrl?: string;
|
|
5
11
|
frontendDir?: string;
|
|
12
|
+
/** Pre-imported plugin init modules — bypasses filesystem discovery (DL#143) */
|
|
13
|
+
plugins?: PreImportedPlugin[];
|
|
14
|
+
/** Pre-imported action modules — bypasses filesystem discovery (DL#143) */
|
|
15
|
+
actionModules?: Array<{
|
|
16
|
+
module: Record<string, unknown>;
|
|
17
|
+
name: string;
|
|
18
|
+
}>;
|
|
6
19
|
}
|
|
7
20
|
export declare function createJayFetchHandler(options: JayFetchHandlerOptions): (request: Request) => Promise<Response>;
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import { FilesystemArtifactStore, matchRequest, fetchPageRequest, fetchActionRequest, isActionRequest, fetchStaticFile, registerActionsFromManifest, initializeServices, } from '@jay-framework/production-server';
|
|
1
|
+
import { FilesystemArtifactStore, matchRequest, fetchPageRequest, fetchActionRequest, isActionRequest, fetchStaticFile, registerActionsFromManifest, registerActionsFromModules, initializeServices, initializeServicesFromModules, } from '@jay-framework/production-server';
|
|
2
2
|
import { parseCookies } from '@jay-framework/stack-server-runtime';
|
|
3
3
|
import { getLogger } from '@jay-framework/logger';
|
|
4
4
|
export function createJayFetchHandler(options) {
|
|
5
|
-
const {
|
|
6
|
-
const artifacts = new FilesystemArtifactStore(backendDir);
|
|
5
|
+
const { staticBaseUrl = '/', frontendDir } = options;
|
|
6
|
+
const artifacts = options.artifactStore ?? new FilesystemArtifactStore(options.backendDir);
|
|
7
|
+
const backendDir = options.backendDir;
|
|
7
8
|
const logger = getLogger();
|
|
8
9
|
let initialized = false;
|
|
9
10
|
async function initialize() {
|
|
10
11
|
const manifest = await artifacts.readManifest();
|
|
11
12
|
logger.info(`[FetchHandler] Loaded manifest: ${manifest.routes.length} routes, v${manifest.version}`);
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
if (options.plugins) {
|
|
14
|
+
await initializeServicesFromModules(options.plugins, 'FetchHandler');
|
|
15
|
+
}
|
|
16
|
+
else if (backendDir) {
|
|
17
|
+
await initializeServices(backendDir, process.cwd(), 'FetchHandler');
|
|
18
|
+
}
|
|
19
|
+
if (options.actionModules) {
|
|
20
|
+
await registerActionsFromModules(options.actionModules);
|
|
21
|
+
}
|
|
22
|
+
else if (manifest.actions.length > 0 && backendDir) {
|
|
14
23
|
await registerActionsFromManifest(manifest.actions, backendDir);
|
|
15
24
|
}
|
|
16
25
|
initialized = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/jay-fetch-handler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
"test": ":"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@jay-framework/logger": "^0.
|
|
20
|
-
"@jay-framework/production-server": "^0.
|
|
19
|
+
"@jay-framework/logger": "^0.18.0",
|
|
20
|
+
"@jay-framework/production-server": "^0.18.0",
|
|
21
|
+
"@jay-framework/stack-server-runtime": "^0.18.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@jay-framework/dev-environment": "^0.
|
|
24
|
+
"@jay-framework/dev-environment": "^0.18.0",
|
|
24
25
|
"@types/node": "^22.15.21",
|
|
25
26
|
"rimraf": "^5.0.5",
|
|
26
27
|
"typescript": "^5.3.3"
|