@fuzdev/fuz_app 0.3.0 → 0.3.2
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/http/route_spec.js
CHANGED
|
@@ -238,6 +238,6 @@ export const apply_route_specs = (app, specs, resolve_auth_guards, log, db) => {
|
|
|
238
238
|
export const prefix_route_specs = (prefix, specs) => {
|
|
239
239
|
return specs.map((spec) => ({
|
|
240
240
|
...spec,
|
|
241
|
-
path: `${prefix}${spec.path}`,
|
|
241
|
+
path: spec.path === '/' ? prefix : `${prefix}${spec.path}`,
|
|
242
242
|
}));
|
|
243
243
|
};
|
package/dist/server/static.d.ts
CHANGED
|
@@ -35,5 +35,6 @@ export type ServeStaticFactory = (options: ServeStaticOptions) => MiddlewareHand
|
|
|
35
35
|
export declare const create_static_middleware: (serve_static: ServeStaticFactory, options?: {
|
|
36
36
|
root?: string;
|
|
37
37
|
spa_fallback?: string;
|
|
38
|
+
is_spa_route?: (path: string) => boolean;
|
|
38
39
|
}) => Array<MiddlewareHandler>;
|
|
39
40
|
//# sourceMappingURL=static.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;AAKpF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACpC,cAAc,kBAAkB,EAChC,UAAU;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAC,KACxF,KAAK,CAAC,iBAAiB,CAyBzB,CAAC"}
|
package/dist/server/static.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
+
/** Default SPA route filter — serves the SPA fallback for all paths except `/api/`. */
|
|
12
|
+
const is_spa_route_default = (path) => !path.startsWith('/api/');
|
|
11
13
|
/**
|
|
12
14
|
* Create static file serving middleware for SvelteKit static builds.
|
|
13
15
|
*
|
|
@@ -32,7 +34,12 @@ export const create_static_middleware = (serve_static, options) => {
|
|
|
32
34
|
// Phase 3: optional SPA fallback for client-side routes
|
|
33
35
|
if (options?.spa_fallback) {
|
|
34
36
|
const fallback = options.spa_fallback;
|
|
35
|
-
|
|
37
|
+
const is_spa_route = options.is_spa_route ?? is_spa_route_default;
|
|
38
|
+
handlers.push(async (c, next) => {
|
|
39
|
+
if (!is_spa_route(c.req.path))
|
|
40
|
+
return next();
|
|
41
|
+
return serve_static({ root, rewriteRequestPath: () => fallback })(c, next);
|
|
42
|
+
});
|
|
36
43
|
}
|
|
37
44
|
return handlers;
|
|
38
45
|
};
|