@scalar/fastify-api-reference 0.8.0 → 0.8.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @scalar/fastify-api-reference
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 11e2f6e: chore: move @scalar/api-reference and terser to devDepdencies
8
+ - daa6928: chore: use fastify-html to send HTML
9
+ - daa6928: chore: disable CommonJS build, don’t support require() anymore
10
+ - 68fedd5: chore: use fastify logging facilities
11
+
3
12
  ## 0.8.0
4
13
 
5
14
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { type ReferenceConfiguration } from '@scalar/api-reference';
1
+ import type { ReferenceConfiguration } from '@scalar/api-reference';
2
2
  import type { FastifyPluginAsync } from 'fastify';
3
3
  export type FastifyApiReferenceOptions = {
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,sBAAsB,CAAA;CACvC,CAAA;AAQD;;GAEG;AACH,eAAO,MAAM,UAAU,i8EA+EtB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,kBAAmB,sBAAsB,WAgB/D,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,sBAAsB,UAqBjE;;AA8ED,wBAAsC"}
1
+ {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAOjD,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,sBAAsB,CAAA;CACvC,CAAA;AAQD;;GAEG;AACH,eAAO,MAAM,UAAU,i8EA+EtB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,kBAAmB,sBAAsB,WAgB/D,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,sBAAsB,UAqBjE;;AAmFD,wBAAsC"}
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ const __dirname = __getDirname();
7
7
  const __filename = __getFilename();
8
8
  const self = globalThis;
9
9
  const require2 = __createRequire(import.meta.url);
10
+ import fastifyHtml from "fastify-html";
10
11
  import fp from "fastify-plugin";
11
12
  import fs from "node:fs";
12
13
  import path from "node:path";
@@ -143,8 +144,11 @@ const fastifyApiReference = async (fastify, options) => {
143
144
  var _a, _b;
144
145
  let { configuration } = options;
145
146
  const hasSwaggerPlugin = fastify.hasPlugin("@fastify/swagger");
147
+ if (!fastify.hasPlugin("fastify-html")) {
148
+ await fastify.register(fastifyHtml);
149
+ }
146
150
  if (!((_a = configuration == null ? void 0 : configuration.spec) == null ? void 0 : _a.content) && !((_b = configuration == null ? void 0 : configuration.spec) == null ? void 0 : _b.url) && !hasSwaggerPlugin) {
147
- console.warn(
151
+ fastify.log.warn(
148
152
  "[@scalar/fastify-api-reference] You didn’t provide a spec.content or spec.url and @fastify/swagger could not be find either. Please provide one of these options."
149
153
  );
150
154
  return;
@@ -175,8 +179,7 @@ const fastifyApiReference = async (fastify, options) => {
175
179
  customCss: defaultCss
176
180
  };
177
181
  }
178
- const html = htmlDocument(configuration);
179
- reply.send(html);
182
+ return reply.html`${htmlDocument(configuration)}`;
180
183
  }
181
184
  });
182
185
  fastify.route({