@scalar/nestjs-api-reference 0.5.3 → 0.5.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Scalar NestJS API Reference Plugin
1
+ # Scalar API Reference Plugin for NestJS
2
2
 
3
3
  [![Version](https://img.shields.io/npm/v/%40scalar/nestjs-api-reference)](https://www.npmjs.com/package/@scalar/nestjs-api-reference)
4
4
  [![Downloads](https://img.shields.io/npm/dm/%40scalar/nestjs-api-reference)](https://www.npmjs.com/package/@scalar/nestjs-api-reference)
@@ -7,91 +7,14 @@
7
7
 
8
8
  This middleware provides an easy way to render a beautiful API reference based on an OpenAPI/Swagger file with NestJS.
9
9
 
10
- ## Installation
10
+ ## Documentation
11
11
 
12
- ```bash
13
- npm install @scalar/nestjs-api-reference
14
- ```
12
+ [Read the documentation here](https://guides.scalar.com/scalar/scalar-api-references/integrations/nestjs)
15
13
 
16
- ## Usage
14
+ ## Community
17
15
 
18
- [Set up NestJS](https://docs.nestjs.com/first-steps) and [set up NestJS Swagger](https://docs.nestjs.com/openapi/introduction) and pass an OpenAPI/Swagger document to the `apiReference` middleware:
16
+ We are API nerds. You too? Let’s chat on Discord: <https://discord.gg/scalar>
19
17
 
20
- ```ts
21
- import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
22
- import { apiReference } from '@scalar/nestjs-api-reference'
18
+ ## License
23
19
 
24
- /* ... */
25
- const app = await NestFactory.create(AppModule)
26
-
27
- const config = new DocumentBuilder()
28
- .setTitle('Cats example')
29
- .setDescription('The cats API description')
30
- .setVersion('1.0')
31
- .addTag('cats')
32
- .build()
33
-
34
- const document = SwaggerModule.createDocument(app, config)
35
- /* ... */
36
-
37
- const OpenApiSpecification =
38
- /* … */
39
-
40
- app.use(
41
- '/reference',
42
- apiReference({
43
- content: document,
44
- }),
45
- )
46
- ```
47
-
48
- Recommended: If you’re serving an OpenAPI/Swagger file already, you can pass an URL, too:
49
-
50
- ```ts
51
- import { apiReference } from '@scalar/nestjs-api-reference'
52
-
53
- app.use(
54
- '/reference',
55
- apiReference({
56
- url: '/openapi.json',
57
- }),
58
- )
59
- ```
60
-
61
- The NestJS middleware takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/tree/main/packages/api-reference#props) in the core package README.
62
-
63
- ### Themes
64
-
65
- The middleware comes with a custom theme for NestJS. You can use one of [the other predefined themes](https://github.com/scalar/scalar/blob/main/packages/themes/src/index.ts#L15) (`alternate`, `default`, `moon`, `purple`, `solarized`) or overwrite it with `none`. All themes come with a light and dark color scheme.
66
-
67
- ```ts
68
- import { apiReference } from '@scalar/nestjs-api-reference'
69
-
70
- app.use(
71
- '/reference',
72
- apiReference({
73
- theme: 'purple',
74
- url: '/openapi.json',
75
- }),
76
- )
77
- ```
78
-
79
- ### Custom CDN
80
-
81
- You can use a custom CDN ,default is `https://cdn.jsdelivr.net/npm/@scalar/api-reference`.
82
-
83
- You can also pin the CDN to a specific version by specifying it in the CDN string like `https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.28`
84
-
85
- You can find all available CDN versions [here](https://www.jsdelivr.com/package/npm/@scalar/api-reference?tab=files)
86
-
87
- ```ts
88
- import { apiReference } from '@scalar/nestjs-api-reference'
89
-
90
- app.use(
91
- '/reference',
92
- apiReference({
93
- cdn: 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@latest',
94
- content: OpenApiSpecification,
95
- }),
96
- )
97
- ```
20
+ The source code in this repository is licensed under [MIT](https://github.com/scalar/scalar/blob/main/LICENSE).
package/dist/index.cjs CHANGED
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -95,7 +96,7 @@ var customThemeCSS = `
95
96
  --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
96
97
  }
97
98
  `;
98
- var ApiReference = (options) => {
99
+ var ApiReference = /* @__PURE__ */ __name((options) => {
99
100
  const configuration = {
100
101
  _integration: "nestjs",
101
102
  ...options
@@ -107,7 +108,7 @@ var ApiReference = (options) => {
107
108
  data-configuration="${JSON.stringify(configuration).split('"').join("&quot;")}">${configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : ""}</script>
108
109
  <script src="${configuration.cdn || "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"></script>
109
110
  `;
110
- };
111
+ }, "ApiReference");
111
112
  function apiReference(options) {
112
113
  const content = `
113
114
  <!DOCTYPE html>
@@ -129,7 +130,9 @@ function apiReference(options) {
129
130
  `;
130
131
  if (options.withFastify) {
131
132
  return (_req, res) => {
132
- res.writeHead(200, { "Content-Type": "text/html" });
133
+ res.writeHead(200, {
134
+ "Content-Type": "text/html"
135
+ });
133
136
  res.write(content);
134
137
  res.end();
135
138
  };
@@ -138,6 +141,7 @@ function apiReference(options) {
138
141
  res.send(content);
139
142
  };
140
143
  }
144
+ __name(apiReference, "apiReference");
141
145
  // Annotate the CommonJS export names for ESM import in node:
142
146
  0 && (module.exports = {
143
147
  ApiReference,
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
1
4
  // src/nestJSApiReference.ts
2
5
  var customThemeCSS = `
3
6
  /* basic theme */
@@ -67,7 +70,7 @@ var customThemeCSS = `
67
70
  --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
68
71
  }
69
72
  `;
70
- var ApiReference = (options) => {
73
+ var ApiReference = /* @__PURE__ */ __name((options) => {
71
74
  const configuration = {
72
75
  _integration: "nestjs",
73
76
  ...options
@@ -79,7 +82,7 @@ var ApiReference = (options) => {
79
82
  data-configuration="${JSON.stringify(configuration).split('"').join("&quot;")}">${configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : ""}</script>
80
83
  <script src="${configuration.cdn || "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"></script>
81
84
  `;
82
- };
85
+ }, "ApiReference");
83
86
  function apiReference(options) {
84
87
  const content = `
85
88
  <!DOCTYPE html>
@@ -101,7 +104,9 @@ function apiReference(options) {
101
104
  `;
102
105
  if (options.withFastify) {
103
106
  return (_req, res) => {
104
- res.writeHead(200, { "Content-Type": "text/html" });
107
+ res.writeHead(200, {
108
+ "Content-Type": "text/html"
109
+ });
105
110
  res.write(content);
106
111
  res.end();
107
112
  };
@@ -110,6 +115,7 @@ function apiReference(options) {
110
115
  res.send(content);
111
116
  };
112
117
  }
118
+ __name(apiReference, "apiReference");
113
119
  export {
114
120
  ApiReference,
115
121
  apiReference,
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "integrations/nestjs"
12
12
  },
13
- "version": "0.5.3",
13
+ "version": "0.5.4",
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },
@@ -37,13 +37,18 @@
37
37
  "@scalar/types": "0.2.3"
38
38
  },
39
39
  "devDependencies": {
40
+ "@nestjs/common": "^11.0.16",
41
+ "@nestjs/platform-fastify": "^10.3.8",
42
+ "@nestjs/testing": "^10.0.0",
40
43
  "@types/express": "^5.0.1",
44
+ "@types/supertest": "^2.0.12",
41
45
  "express": "^5.1.0",
42
46
  "fastify": "^4.26.2",
47
+ "supertest": "^6.3.3",
43
48
  "tsup": "^8.3.5",
44
49
  "vite": "5.4.19",
45
50
  "vitest": "^1.6.0",
46
- "@scalar/api-reference": "1.31.9"
51
+ "@scalar/api-reference": "1.31.15"
47
52
  },
48
53
  "scripts": {
49
54
  "build": "tsup ./src/index.ts --format esm,cjs --dts",
@@ -57,7 +62,7 @@
57
62
  "docker:run-fastify": "docker run -p 5057:5057 nestjs-api-reference-fastify",
58
63
  "lint:check": "eslint .",
59
64
  "lint:fix": "eslint . --fix",
60
- "test": "vitest run",
65
+ "test": "vitest",
61
66
  "types:check": "tsc --noEmit"
62
67
  }
63
68
  }