@taujs/server 0.3.2 → 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 } 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,6 +69,10 @@ type SSRServerOptions = {
69
69
  generateCSP?: (directives: CSPDirectives, nonce: string) => string;
70
70
  };
71
71
  };
72
+ registerStaticAssets?: false | {
73
+ plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
74
+ options?: Record<string, unknown>;
75
+ };
72
76
  isDebug?: boolean;
73
77
  };
74
78
  type ServiceMethod = (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
@@ -102,6 +106,7 @@ type RenderModule = {
102
106
  renderSSR: RenderSSR;
103
107
  renderStream: RenderStream;
104
108
  };
109
+ type GenericPlugin = FastifyPluginCallback<Record<string, unknown>> | FastifyPluginAsync<Record<string, unknown>>;
105
110
  type BaseMiddleware = {
106
111
  auth?: {
107
112
  required: boolean;
@@ -145,4 +150,4 @@ interface InitialRouteParams extends Record<string, unknown> {
145
150
  type RouteParams = InitialRouteParams & Record<string, unknown>;
146
151
  type RoutePathsAndAttributes<Params = {}> = Omit<Route<Params>, 'element'>;
147
152
 
148
- 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-D_82uJ06.js';
3
+ import './SSRServer-DPZped7n.js';
4
4
  import 'node:http';
5
5
  import 'fastify';
6
6
 
package/dist/build.js CHANGED
@@ -538,12 +538,16 @@ var SSRServer = (0, import_fastify_plugin.default)(
538
538
  ],
539
539
  opts.isDebug
540
540
  );
541
- await app.register(import("@fastify/static"), {
542
- index: false,
543
- prefix: "/",
544
- root: baseClientRoot,
545
- wildcard: false
546
- });
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
+ });
550
+ }
547
551
  app.addHook(
548
552
  "onRequest",
549
553
  createCSPHook({
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-D_82uJ06.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-D_82uJ06.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,12 +536,16 @@ var SSRServer = (0, import_fastify_plugin.default)(
536
536
  ],
537
537
  opts.isDebug
538
538
  );
539
- await app.register(import("@fastify/static"), {
540
- index: false,
541
- prefix: "/",
542
- root: baseClientRoot,
543
- wildcard: false
544
- });
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
+ });
548
+ }
545
549
  app.addHook(
546
550
  "onRequest",
547
551
  createCSPHook({
@@ -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-D_82uJ06.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.2",
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",
@@ -47,7 +47,6 @@
47
47
  "dist"
48
48
  ],
49
49
  "dependencies": {
50
- "@fastify/static": "^8.0.3",
51
50
  "path-to-regexp": "^8.1.0",
52
51
  "vite-plugin-node-polyfills": "^0.23.0"
53
52
  },
@@ -55,6 +54,7 @@
55
54
  "@arethetypeswrong/cli": "^0.15.4",
56
55
  "@babel/preset-typescript": "^7.24.7",
57
56
  "@changesets/cli": "^2.27.7",
57
+ "@fastify/static": "^8.0.3",
58
58
  "@types/node": "^20.14.9",
59
59
  "@vitest/coverage-v8": "^2.1.0",
60
60
  "@vitest/ui": "^2.1.9",
@@ -67,10 +67,16 @@
67
67
  "vitest": "^2.0.5"
68
68
  },
69
69
  "peerDependencies": {
70
+ "@fastify/static": "^8.0.3",
70
71
  "fastify": "^5.3.3",
71
72
  "typescript": "^5.5.4",
72
73
  "vite": "^6.3.5"
73
74
  },
75
+ "peerDependenciesMeta": {
76
+ "@fastify/static": {
77
+ "optional": true
78
+ }
79
+ },
74
80
  "scripts": {
75
81
  "build": "tsup",
76
82
  "build-local": "tsup && ./move.sh",