@taujs/server 0.3.3 → 0.3.4

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.
@@ -1,5 +1,5 @@
1
1
  import { ServerResponse } from 'node:http';
2
- import { FastifyRequest, FastifyReply, HookHandlerDoneFunction, FastifyPluginAsync, FastifyInstance } from 'fastify';
2
+ import { FastifyRequest, FastifyReply, HookHandlerDoneFunction, FastifyPluginAsync, FastifyPluginCallback } from 'fastify';
3
3
  import { PluginOption } from 'vite';
4
4
 
5
5
  type CSPDirectives = Record<string, string[]>;
@@ -69,7 +69,10 @@ type SSRServerOptions = {
69
69
  generateCSP?: (directives: CSPDirectives, nonce: string) => string;
70
70
  };
71
71
  };
72
- registerStaticAssets?: false | ((app: FastifyInstance) => Promise<void> | void);
72
+ registerStaticAssets?: false | {
73
+ plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
74
+ options?: Record<string, unknown>;
75
+ };
73
76
  isDebug?: boolean;
74
77
  };
75
78
  type ServiceMethod = (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
@@ -103,6 +106,7 @@ type RenderModule = {
103
106
  renderSSR: RenderSSR;
104
107
  renderStream: RenderStream;
105
108
  };
109
+ type GenericPlugin = FastifyPluginCallback<Record<string, unknown>> | FastifyPluginAsync<Record<string, unknown>>;
106
110
  type BaseMiddleware = {
107
111
  auth?: {
108
112
  required: boolean;
@@ -146,4 +150,4 @@ interface InitialRouteParams extends Record<string, unknown> {
146
150
  type RouteParams = InitialRouteParams & Record<string, unknown>;
147
151
  type RoutePathsAndAttributes<Params = {}> = Omit<Route<Params>, 'element'>;
148
152
 
149
- export { type BaseMiddleware as B, type Config as C, type DataResult as D, type InitialRouteParams as I, type ManifestEntry as M, type NamedService as N, type ProcessedConfig as P, type Route as R, SSRServer as S, TEMPLATE as T, type RouteParams as a, type RouteAttributes as b, createMaps as c, type SSRServerOptions as d, type ServiceMethod as e, type ServiceRegistry as f, type RenderCallbacks as g, type SSRManifest as h, type Manifest as i, type RenderSSR as j, type RenderStream as k, type RenderModule as l, type ServiceCall as m, type DataHandler as n, type RoutePathsAndAttributes as o, processConfigs as p, type CSPDirectives as q, type CSPOptions as r, defaultGenerateCSP as s, generateNonce as t, createCSPHook as u, getRequestNonce as v, applyCSP as w };
153
+ export { type BaseMiddleware as B, type Config as C, type DataResult as D, type GenericPlugin as G, type InitialRouteParams as I, type ManifestEntry as M, type NamedService as N, type ProcessedConfig as P, type Route as R, SSRServer as S, TEMPLATE as T, type RouteParams as a, type RouteAttributes as b, createMaps as c, type SSRServerOptions as d, type ServiceMethod as e, type ServiceRegistry as f, type RenderCallbacks as g, type SSRManifest as h, type Manifest as i, type RenderSSR as j, type RenderStream as k, type RenderModule as l, type ServiceCall as m, type DataHandler as n, type RoutePathsAndAttributes as o, processConfigs as p, type CSPDirectives as q, type CSPOptions as r, defaultGenerateCSP as s, generateNonce as t, createCSPHook as u, getRequestNonce as v, applyCSP as w };
package/dist/build.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AppConfig } from './config.js';
2
2
  import 'vite';
3
- import './SSRServer-C9yjcgke.js';
3
+ import './SSRServer-DPZped7n.js';
4
4
  import 'node:http';
5
5
  import 'fastify';
6
6
 
package/dist/build.js CHANGED
@@ -538,24 +538,15 @@ var SSRServer = (0, import_fastify_plugin.default)(
538
538
  ],
539
539
  opts.isDebug
540
540
  );
541
- if (opts.registerStaticAssets !== false) {
542
- if (typeof opts.registerStaticAssets === "function") {
543
- await opts.registerStaticAssets(app);
544
- } else {
545
- try {
546
- const fastifyStatic = await import("@fastify/static");
547
- await app.register(fastifyStatic.default, {
548
- index: false,
549
- prefix: "/",
550
- root: baseClientRoot,
551
- wildcard: false
552
- });
553
- } catch (err) {
554
- throw new Error(
555
- "Static asset handling requires @fastify/static to be installed. Either install it or provide your own static asset handler using `registerStaticAssets`."
556
- );
557
- }
558
- }
541
+ if (opts.registerStaticAssets && typeof opts.registerStaticAssets === "object") {
542
+ const { plugin, options } = opts.registerStaticAssets;
543
+ await app.register(plugin, {
544
+ root: baseClientRoot,
545
+ prefix: "/",
546
+ index: false,
547
+ wildcard: false,
548
+ ...options ?? {}
549
+ });
559
550
  }
560
551
  app.addHook(
561
552
  "onRequest",
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PluginOption } from 'vite';
2
- import { R as Route, a as RouteParams, b as RouteAttributes } from './SSRServer-C9yjcgke.js';
2
+ import { R as Route, a as RouteParams, b as RouteAttributes } from './SSRServer-DPZped7n.js';
3
3
  import 'node:http';
4
4
  import 'fastify';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FastifyReply } from 'fastify';
2
- export { B as BaseMiddleware, C as Config, n as DataHandler, D as DataResult, I as InitialRouteParams, i as Manifest, M as ManifestEntry, N as NamedService, P as ProcessedConfig, g as RenderCallbacks, l as RenderModule, j as RenderSSR, k as RenderStream, R as Route, b as RouteAttributes, a as RouteParams, o as RoutePathsAndAttributes, h as SSRManifest, S as SSRServer, d as SSRServerOptions, m as ServiceCall, e as ServiceMethod, f as ServiceRegistry, T as TEMPLATE, c as createMaps, p as processConfigs } from './SSRServer-C9yjcgke.js';
2
+ export { B as BaseMiddleware, C as Config, n as DataHandler, D as DataResult, G as GenericPlugin, I as InitialRouteParams, i as Manifest, M as ManifestEntry, N as NamedService, P as ProcessedConfig, g as RenderCallbacks, l as RenderModule, j as RenderSSR, k as RenderStream, R as Route, b as RouteAttributes, a as RouteParams, o as RoutePathsAndAttributes, h as SSRManifest, S as SSRServer, d as SSRServerOptions, m as ServiceCall, e as ServiceMethod, f as ServiceRegistry, T as TEMPLATE, c as createMaps, p as processConfigs } from './SSRServer-DPZped7n.js';
3
3
  import 'node:http';
4
4
  import 'vite';
5
5
 
package/dist/index.js CHANGED
@@ -536,24 +536,15 @@ var SSRServer = (0, import_fastify_plugin.default)(
536
536
  ],
537
537
  opts.isDebug
538
538
  );
539
- if (opts.registerStaticAssets !== false) {
540
- if (typeof opts.registerStaticAssets === "function") {
541
- await opts.registerStaticAssets(app);
542
- } else {
543
- try {
544
- const fastifyStatic = await import("@fastify/static");
545
- await app.register(fastifyStatic.default, {
546
- index: false,
547
- prefix: "/",
548
- root: baseClientRoot,
549
- wildcard: false
550
- });
551
- } catch (err) {
552
- throw new Error(
553
- "Static asset handling requires @fastify/static to be installed. Either install it or provide your own static asset handler using `registerStaticAssets`."
554
- );
555
- }
556
- }
539
+ if (opts.registerStaticAssets && typeof opts.registerStaticAssets === "object") {
540
+ const { plugin, options } = opts.registerStaticAssets;
541
+ await app.register(plugin, {
542
+ root: baseClientRoot,
543
+ prefix: "/",
544
+ index: false,
545
+ wildcard: false,
546
+ ...options ?? {}
547
+ });
557
548
  }
558
549
  app.addHook(
559
550
  "onRequest",
@@ -1,4 +1,4 @@
1
1
  import 'fastify';
2
- export { q as CSPDirectives, r as CSPOptions, w as applyCSP, u as createCSPHook, s as defaultGenerateCSP, t as generateNonce, v as getRequestNonce } from '../SSRServer-C9yjcgke.js';
2
+ export { q as CSPDirectives, r as CSPOptions, w as applyCSP, u as createCSPHook, s as defaultGenerateCSP, t as generateNonce, v as getRequestNonce } from '../SSRServer-DPZped7n.js';
3
3
  import 'node:http';
4
4
  import 'vite';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taujs/server",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "taujs [ τjs ]",
5
5
  "author": "John Smith | Aoede <taujs@aoede.uk.net> (https://www.aoede.uk.net)",
6
6
  "license": "MIT",