@scalar/fastify-api-reference 0.6.1 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE;QACZ,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACxD,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;;AA4CD,wBAAsC"}
1
+ {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE;QACZ,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACxD,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;;AA0CD,wBAAsC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ const ejs = require("ejs");
3
+ const fp = require("fastify-plugin");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const fastifyApiReference = async (fastify, options) => {
7
+ var _a, _b;
8
+ if (!((_a = options.apiReference) == null ? void 0 : _a.spec) && !((_b = options.apiReference) == null ? void 0 : _b.specUrl)) {
9
+ console.warn(
10
+ "[@scalar/fastify-api-reference] You didn’t provide a spec or specUrl. Please provide one of these options."
11
+ );
12
+ return;
13
+ }
14
+ fastify.get(options.routePrefix ?? "/", async (_, reply) => {
15
+ reply.header("Content-Type", "text/html; charset=utf-8");
16
+ const html = await ejs.renderFile(
17
+ path.resolve(`${__dirname}/../dist/templates/index.ejs`),
18
+ {
19
+ options
20
+ }
21
+ );
22
+ reply.send(html);
23
+ });
24
+ fastify.get(
25
+ (options.routePrefix ?? "/") + "/fastify-api-reference.js",
26
+ async (_, reply) => {
27
+ reply.header("Content-Type", "application/javascript; charset=utf-8");
28
+ const content = fs.readFileSync(
29
+ path.resolve(`${__dirname}/../dist/templates/fastify-api-reference.js`),
30
+ "utf8"
31
+ );
32
+ reply.send(content);
33
+ }
34
+ );
35
+ };
36
+ const fastifyApiReference$1 = fp(fastifyApiReference);
37
+ module.exports = fastifyApiReference$1;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default } from './fastifyApiReference.js';
1
+ export { default } from './fastifyApiReference';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1 +1,47 @@
1
- export { default } from './fastifyApiReference.js';
1
+ import __path from "path";
2
+ import { fileURLToPath as __fileURLToPath } from "url";
3
+ import { createRequire as __createRequire } from "module";
4
+ const __getFilename = () => __fileURLToPath(import.meta.url);
5
+ const __getDirname = () => __path.dirname(__getFilename());
6
+ const __dirname = __getDirname();
7
+ const __filename = __getFilename();
8
+ const self = globalThis;
9
+ const require2 = __createRequire(import.meta.url);
10
+ import ejs from "ejs";
11
+ import fp from "fastify-plugin";
12
+ import fs from "node:fs";
13
+ import path from "node:path";
14
+ const fastifyApiReference = async (fastify, options) => {
15
+ var _a, _b;
16
+ if (!((_a = options.apiReference) == null ? void 0 : _a.spec) && !((_b = options.apiReference) == null ? void 0 : _b.specUrl)) {
17
+ console.warn(
18
+ "[@scalar/fastify-api-reference] You didn’t provide a spec or specUrl. Please provide one of these options."
19
+ );
20
+ return;
21
+ }
22
+ fastify.get(options.routePrefix ?? "/", async (_, reply) => {
23
+ reply.header("Content-Type", "text/html; charset=utf-8");
24
+ const html = await ejs.renderFile(
25
+ path.resolve(`${__dirname}/../dist/templates/index.ejs`),
26
+ {
27
+ options
28
+ }
29
+ );
30
+ reply.send(html);
31
+ });
32
+ fastify.get(
33
+ (options.routePrefix ?? "/") + "/fastify-api-reference.js",
34
+ async (_, reply) => {
35
+ reply.header("Content-Type", "application/javascript; charset=utf-8");
36
+ const content = fs.readFileSync(
37
+ path.resolve(`${__dirname}/../dist/templates/fastify-api-reference.js`),
38
+ "utf8"
39
+ );
40
+ reply.send(content);
41
+ }
42
+ );
43
+ };
44
+ const fastifyApiReference$1 = fp(fastifyApiReference);
45
+ export {
46
+ fastifyApiReference$1 as default
47
+ };