fastify-txstate 3.3.2 → 3.3.3

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/lib/index.d.ts CHANGED
@@ -133,6 +133,7 @@ export default class Server {
133
133
  protected validOrigins: Record<string, boolean>;
134
134
  protected validOriginHosts: Record<string, boolean>;
135
135
  protected validOriginSuffixes: Set<string>;
136
+ protected swaggerEndpoint: string | undefined;
136
137
  app: FastifyInstanceTyped;
137
138
  constructor(config?: FastifyTxStateOptions & {
138
139
  http2?: true;
package/lib/index.js CHANGED
@@ -73,6 +73,7 @@ class Server {
73
73
  validOrigins = {};
74
74
  validOriginHosts = {};
75
75
  validOriginSuffixes = new Set();
76
+ swaggerEndpoint;
76
77
  app;
77
78
  constructor(config = {}) {
78
79
  this.config = config;
@@ -210,7 +211,7 @@ class Server {
210
211
  DELETE: true
211
212
  };
212
213
  this.app.addHook('onRequest', async (req, res) => {
213
- if (!authenticatedMethods[req.method] || req.routeOptions.url === '/health')
214
+ if (!authenticatedMethods[req.method] || req.routeOptions.url === '/health' || (this.swaggerEndpoint && req.routeOptions.url?.startsWith(this.swaggerEndpoint)))
214
215
  return;
215
216
  try {
216
217
  req.auth = await config.authenticate(req);
@@ -394,7 +395,8 @@ this is log into this application and use dev tools to pull your token from the
394
395
  return { schema: newSchema, url, route, swaggerObject, openapiObject };
395
396
  }
396
397
  });
397
- await this.app.register(swagger_ui_1.default, { ...opts?.ui, routePrefix: opts?.path ?? opts?.ui?.routePrefix ?? '/docs' });
398
+ this.swaggerEndpoint = opts?.path ?? opts?.ui?.routePrefix ?? '/docs';
399
+ await this.app.register(swagger_ui_1.default, { ...opts?.ui, routePrefix: this.swaggerEndpoint });
398
400
  }
399
401
  async close(softSeconds) {
400
402
  if (typeof softSeconds === 'undefined')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-txstate",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "A small wrapper for fastify providing a set of common conventions & utility functions we use.",
5
5
  "exports": {
6
6
  ".": {