@taujs/server 0.4.5 → 0.4.6

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -98
  2. package/package.json +4 -11
package/dist/index.js CHANGED
@@ -97,101 +97,10 @@ var require_picocolors = __commonJS({
97
97
  }
98
98
  });
99
99
 
100
- // node_modules/fastify-plugin/lib/getPluginName.js
101
- var require_getPluginName = __commonJS({
102
- "node_modules/fastify-plugin/lib/getPluginName.js"(exports, module) {
103
- "use strict";
104
- var fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/;
105
- var fileNamePattern = /(\w*(\.\w*)*)\..*/;
106
- module.exports = function getPluginName(fn) {
107
- if (fn.name.length > 0) return fn.name;
108
- const stackTraceLimit = Error.stackTraceLimit;
109
- Error.stackTraceLimit = 10;
110
- try {
111
- throw new Error("anonymous function");
112
- } catch (e) {
113
- Error.stackTraceLimit = stackTraceLimit;
114
- return extractPluginName(e.stack);
115
- }
116
- };
117
- function extractPluginName(stack) {
118
- const m = stack.match(fpStackTracePattern);
119
- return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : "anonymous";
120
- }
121
- module.exports.extractPluginName = extractPluginName;
122
- }
123
- });
124
-
125
- // node_modules/fastify-plugin/lib/toCamelCase.js
126
- var require_toCamelCase = __commonJS({
127
- "node_modules/fastify-plugin/lib/toCamelCase.js"(exports, module) {
128
- "use strict";
129
- module.exports = function toCamelCase(name) {
130
- if (name[0] === "@") {
131
- name = name.slice(1).replace("/", "-");
132
- }
133
- return name.replace(/-(.)/g, function(match2, g1) {
134
- return g1.toUpperCase();
135
- });
136
- };
137
- }
138
- });
139
-
140
- // node_modules/fastify-plugin/plugin.js
141
- var require_plugin = __commonJS({
142
- "node_modules/fastify-plugin/plugin.js"(exports, module) {
143
- "use strict";
144
- var getPluginName = require_getPluginName();
145
- var toCamelCase = require_toCamelCase();
146
- var count = 0;
147
- function plugin(fn, options = {}) {
148
- let autoName = false;
149
- if (fn.default !== void 0) {
150
- fn = fn.default;
151
- }
152
- if (typeof fn !== "function") {
153
- throw new TypeError(
154
- `fastify-plugin expects a function, instead got a '${typeof fn}'`
155
- );
156
- }
157
- if (typeof options === "string") {
158
- options = {
159
- fastify: options
160
- };
161
- }
162
- if (typeof options !== "object" || Array.isArray(options) || options === null) {
163
- throw new TypeError("The options object should be an object");
164
- }
165
- if (options.fastify !== void 0 && typeof options.fastify !== "string") {
166
- throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`);
167
- }
168
- if (!options.name) {
169
- autoName = true;
170
- options.name = getPluginName(fn) + "-auto-" + count++;
171
- }
172
- fn[Symbol.for("skip-override")] = options.encapsulate !== true;
173
- fn[Symbol.for("fastify.display-name")] = options.name;
174
- fn[Symbol.for("plugin-meta")] = options;
175
- if (!fn.default) {
176
- fn.default = fn;
177
- }
178
- const camelCase = toCamelCase(options.name);
179
- if (!autoName && !fn[camelCase]) {
180
- fn[camelCase] = fn;
181
- }
182
- return fn;
183
- }
184
- module.exports = plugin;
185
- module.exports.default = plugin;
186
- module.exports.fastifyPlugin = plugin;
187
- }
188
- });
189
-
190
100
  // src/CreateServer.ts
191
101
  var import_picocolors4 = __toESM(require_picocolors(), 1);
192
102
  import path7 from "path";
193
103
  import { performance as performance3 } from "perf_hooks";
194
- import fastifyStatic from "@fastify/static";
195
104
  import Fastify from "fastify";
196
105
 
197
106
  // src/Setup.ts
@@ -851,8 +760,8 @@ var verifyContracts = (app, routes, contracts, security) => {
851
760
  };
852
761
 
853
762
  // src/SSRServer.ts
854
- var import_fastify_plugin3 = __toESM(require_plugin(), 1);
855
763
  import path6 from "path";
764
+ import fp3 from "fastify-plugin";
856
765
 
857
766
  // src/logging/utils/index.ts
858
767
  var httpStatusFrom = (err, fallback = 500) => err instanceof AppError ? err.httpStatus : fallback;
@@ -1083,7 +992,7 @@ var createAuthHook = (routeMatchers, logger) => {
1083
992
  };
1084
993
 
1085
994
  // src/security/CSP.ts
1086
- var import_fastify_plugin = __toESM(require_plugin(), 1);
995
+ import fp from "fastify-plugin";
1087
996
  import crypto from "crypto";
1088
997
 
1089
998
  // src/utils/System.ts
@@ -1129,7 +1038,7 @@ var findMatchingRoute = (routeMatchers, path9) => {
1129
1038
  const match2 = matchRoute(path9, routeMatchers);
1130
1039
  return match2 ? { route: match2.route, params: match2.params } : null;
1131
1040
  };
1132
- var cspPlugin = (0, import_fastify_plugin.default)(
1041
+ var cspPlugin = fp(
1133
1042
  async (fastify, opts) => {
1134
1043
  const { generateCSP = defaultGenerateCSP, routes = [], routeMatchers, debug } = opts;
1135
1044
  const globalDirectives = opts.directives || DEV_CSP_DIRECTIVES;
@@ -1180,7 +1089,7 @@ var cspPlugin = (0, import_fastify_plugin.default)(
1180
1089
  );
1181
1090
 
1182
1091
  // src/security/CSPReporting.ts
1183
- var import_fastify_plugin2 = __toESM(require_plugin(), 1);
1092
+ import fp2 from "fastify-plugin";
1184
1093
  function sanitiseContext(ctx) {
1185
1094
  return {
1186
1095
  userAgent: ctx.userAgent,
@@ -1263,7 +1172,7 @@ var processCSPReport = (body, context, logger) => {
1263
1172
  );
1264
1173
  }
1265
1174
  };
1266
- var cspReportPlugin = (0, import_fastify_plugin2.default)(
1175
+ var cspReportPlugin = fp2(
1267
1176
  async (fastify, opts) => {
1268
1177
  const { onViolation } = opts;
1269
1178
  if (!opts.path || typeof opts.path !== "string") throw AppError.badRequest("CSP report path is required and must be a string");
@@ -2018,7 +1927,7 @@ async function registerStaticAssets(app, baseClientRoot, reg, defaults, projectR
2018
1927
  }
2019
1928
 
2020
1929
  // src/SSRServer.ts
2021
- var SSRServer = (0, import_fastify_plugin3.default)(
1930
+ var SSRServer = fp3(
2022
1931
  async (app, opts) => {
2023
1932
  const { alias, configs, routes, serviceRegistry = {}, clientRoot: baseClientRoot, security } = opts;
2024
1933
  const logger = createLogger({
@@ -2183,7 +2092,7 @@ var createServer = async (opts) => {
2183
2092
  configs,
2184
2093
  routes,
2185
2094
  serviceRegistry: opts.serviceRegistry,
2186
- staticAssets: opts.staticAssets !== void 0 ? opts.staticAssets : { plugin: fastifyStatic },
2095
+ staticAssets: opts.staticAssets ?? false,
2187
2096
  debug: opts.debug,
2188
2097
  alias: opts.alias,
2189
2098
  security,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taujs/server",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "τjs [ taujs ]",
5
5
  "author": "John Smith | Aoede <taujs@aoede.uk.net> (https://www.aoede.uk.net)",
6
6
  "license": "MIT",
@@ -44,36 +44,29 @@
44
44
  "dist"
45
45
  ],
46
46
  "dependencies": {
47
+ "fastify": "^5.6.1",
48
+ "fastify-plugin": "^5.1.0",
47
49
  "path-to-regexp": "^8.1.0",
48
- "vite-plugin-node-polyfills": "^0.24.0"
50
+ "vite": "^7.1.11"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@arethetypeswrong/cli": "^0.15.4",
52
54
  "@babel/preset-typescript": "^7.24.7",
53
55
  "@changesets/cli": "^2.27.7",
54
- "@fastify/static": "^8.3.0",
55
56
  "@types/node": "^20.14.9",
56
57
  "@vitest/coverage-v8": "^3.2.4",
57
58
  "@vitest/ui": "^3.2.4",
58
- "fastify": "^5.6.1",
59
59
  "jsdom": "^25.0.0",
60
60
  "prettier": "^3.3.3",
61
61
  "tsup": "^8.2.4",
62
62
  "typescript": "^5.5.4",
63
- "vite": "^7.1.11",
64
63
  "vitest": "^3.2.4"
65
64
  },
66
65
  "peerDependencies": {
67
- "@fastify/static": "^8.3.0",
68
66
  "fastify": "^5.6.1",
69
67
  "typescript": "^5.5.4",
70
68
  "vite": "^7.1.11"
71
69
  },
72
- "peerDependenciesMeta": {
73
- "@fastify/static": {
74
- "optional": true
75
- }
76
- },
77
70
  "scripts": {
78
71
  "build": "tsup",
79
72
  "build-local": "tsup && ./move.sh",