@scalar/nestjs-api-reference 0.5.14 → 1.0.0
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/dist/index.cjs +12 -36
- package/dist/index.d.cts +7 -13
- package/dist/index.d.ts +7 -13
- package/dist/index.js +12 -35
- package/package.json +10 -8
package/dist/index.cjs
CHANGED
|
@@ -21,17 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
|
-
ApiReference: () => ApiReference,
|
|
25
24
|
apiReference: () => apiReference,
|
|
26
25
|
customThemeCSS: () => customThemeCSS
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(index_exports);
|
|
29
28
|
|
|
30
29
|
// src/nestJSApiReference.ts
|
|
30
|
+
var import_html_rendering = require("@scalar/core/libs/html-rendering");
|
|
31
31
|
var customThemeCSS = `
|
|
32
32
|
/* basic theme */
|
|
33
33
|
.light-mode {
|
|
34
|
-
--scalar-color-1: #
|
|
34
|
+
--scalar-color-1: #1b1b1b;
|
|
35
35
|
--scalar-color-2: #757575;
|
|
36
36
|
--scalar-color-3: #8e8e8e;
|
|
37
37
|
--scalar-color-accent: #e0234d;
|
|
@@ -96,55 +96,31 @@ var customThemeCSS = `
|
|
|
96
96
|
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
97
97
|
}
|
|
98
98
|
`;
|
|
99
|
-
var
|
|
99
|
+
var DEFAULT_CONFIGURATION = {
|
|
100
|
+
_integration: "nestjs"
|
|
101
|
+
};
|
|
102
|
+
function apiReference(givenConfiguration) {
|
|
100
103
|
const configuration = {
|
|
101
|
-
|
|
102
|
-
...
|
|
104
|
+
...DEFAULT_CONFIGURATION,
|
|
105
|
+
...givenConfiguration
|
|
103
106
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
id="api-reference"
|
|
107
|
-
type="application/json"
|
|
108
|
-
data-configuration="${JSON.stringify(configuration).split('"').join(""")}">${configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : ""}</script>
|
|
109
|
-
<script src="${configuration.cdn || "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"></script>
|
|
110
|
-
`;
|
|
111
|
-
}, "ApiReference");
|
|
112
|
-
function apiReference(options) {
|
|
113
|
-
const content = `
|
|
114
|
-
<!DOCTYPE html>
|
|
115
|
-
<html>
|
|
116
|
-
<head>
|
|
117
|
-
<title>${options.title || "Scalar API Reference"}</title>
|
|
118
|
-
<meta charset="utf-8" />
|
|
119
|
-
<meta
|
|
120
|
-
name="viewport"
|
|
121
|
-
content="width=device-width, initial-scale=1" />
|
|
122
|
-
<style>
|
|
123
|
-
${options.theme ? null : customThemeCSS}
|
|
124
|
-
</style>
|
|
125
|
-
</head>
|
|
126
|
-
<body>
|
|
127
|
-
${ApiReference(options)}
|
|
128
|
-
</body>
|
|
129
|
-
</html>
|
|
130
|
-
`;
|
|
131
|
-
if (options.withFastify) {
|
|
107
|
+
const content = /* @__PURE__ */ __name(() => (0, import_html_rendering.getHtmlDocument)(configuration, customThemeCSS), "content");
|
|
108
|
+
if (givenConfiguration.withFastify) {
|
|
132
109
|
return (_req, res) => {
|
|
133
110
|
res.writeHead(200, {
|
|
134
111
|
"Content-Type": "text/html"
|
|
135
112
|
});
|
|
136
|
-
res.write(content);
|
|
113
|
+
res.write(content());
|
|
137
114
|
res.end();
|
|
138
115
|
};
|
|
139
116
|
}
|
|
140
117
|
return (_req, res) => {
|
|
141
|
-
res.send(content);
|
|
118
|
+
res.send(content());
|
|
142
119
|
};
|
|
143
120
|
}
|
|
144
121
|
__name(apiReference, "apiReference");
|
|
145
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
146
123
|
0 && (module.exports = {
|
|
147
|
-
ApiReference,
|
|
148
124
|
apiReference,
|
|
149
125
|
customThemeCSS
|
|
150
126
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { ServerResponse } from 'node:http';
|
|
2
|
-
import { ApiReferenceConfiguration } from '@scalar/types/api-reference';
|
|
3
2
|
import { Request, Response } from 'express';
|
|
4
3
|
import { FastifyRequest } from 'fastify';
|
|
4
|
+
import { HtmlRenderingConfiguration } from '@scalar/core/libs/html-rendering';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type ApiReferenceOptions = Partial<HtmlRenderingConfiguration>;
|
|
7
|
+
type NestJSReferenceConfiguration = ApiReferenceOptions & {
|
|
7
8
|
withFastify?: boolean;
|
|
8
|
-
cdn?: string;
|
|
9
|
-
};
|
|
10
|
-
type ApiReferenceOptions = Partial<ApiReferenceConfiguration> & {
|
|
11
|
-
cdn?: string;
|
|
12
9
|
};
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* The custom theme CSS for the API Reference.
|
|
15
13
|
*/
|
|
16
|
-
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #
|
|
17
|
-
/**
|
|
18
|
-
* The HTML to load the @scalar/api-reference package.
|
|
19
|
-
*/
|
|
20
|
-
declare const ApiReference: (options: ApiReferenceOptions) => string;
|
|
14
|
+
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #1b1b1b;\n --scalar-color-2: #757575;\n --scalar-color-3: #8e8e8e;\n --scalar-color-accent: #e0234d;\n --scalar-background-1: #fff;\n --scalar-background-2: #f6f6f6;\n --scalar-background-3: #e7e7e7;\n --scalar-background-accent: #8ab4f81f;\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 1);\n --scalar-color-2: #b2bac2;\n --scalar-color-3: #6e748b;\n --scalar-color-accent: #e0234d;\n --scalar-background-1: #11131e;\n --scalar-background-2: #1c2132;\n --scalar-background-3: #2f354a;\n --scalar-background-accent: #8ab4f81f;\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n/* Document Sidebar */\n.light-mode .t-doc__sidebar,\n.dark-mode .t-doc__sidebar {\n --scalar-sidebar-background-1: var(--scalar-background-1);\n --scalar-sidebar-item-hover-color: currentColor;\n --scalar-sidebar-item-hover-background: var(--scalar-background-2);\n --scalar-sidebar-item-active-background: var(--scalar-background-3);\n --scalar-sidebar-border-color: var(--scalar-border-color);\n --scalar-sidebar-color-1: var(--scalar-color-1);\n --scalar-sidebar-color-2: var(--scalar-color-2);\n --scalar-sidebar-color-active: var(--scalar-color-1);\n --scalar-sidebar-search-background: var(--scalar-background-2);\n --scalar-sidebar-search-border-color: var(--scalar-background-2);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n/* advanced */\n.light-mode {\n --scalar-button-1: rgb(49 53 56);\n --scalar-button-1-color: #fff;\n --scalar-button-1-hover: rgb(28 31 33);\n --scalar-color-green: #069061;\n --scalar-color-red: #ef0006;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0082d0;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);\n --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n}\n.dark-mode {\n --scalar-button-1: #f6f6f6;\n --scalar-button-1-color: #000;\n --scalar-button-1-hover: #e7e7e7;\n --scalar-color-green: #30beb0;\n --scalar-color-red: #e91e63;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #2cb6f6;\n --scalar-color-orange: #ff5656;\n --scalar-color-purple: #6223e0;\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n";
|
|
21
15
|
/**
|
|
22
16
|
* The HTML template to render the API Reference.
|
|
23
17
|
*/
|
|
24
|
-
declare function apiReference(
|
|
18
|
+
declare function apiReference(givenConfiguration: NestJSReferenceConfiguration): ((_req: FastifyRequest, res: ServerResponse) => void) | ((_req: Request, res: Response) => void);
|
|
25
19
|
|
|
26
|
-
export {
|
|
20
|
+
export { type ApiReferenceOptions, type NestJSReferenceConfiguration, apiReference, customThemeCSS };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { ServerResponse } from 'node:http';
|
|
2
|
-
import { ApiReferenceConfiguration } from '@scalar/types/api-reference';
|
|
3
2
|
import { Request, Response } from 'express';
|
|
4
3
|
import { FastifyRequest } from 'fastify';
|
|
4
|
+
import { HtmlRenderingConfiguration } from '@scalar/core/libs/html-rendering';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type ApiReferenceOptions = Partial<HtmlRenderingConfiguration>;
|
|
7
|
+
type NestJSReferenceConfiguration = ApiReferenceOptions & {
|
|
7
8
|
withFastify?: boolean;
|
|
8
|
-
cdn?: string;
|
|
9
|
-
};
|
|
10
|
-
type ApiReferenceOptions = Partial<ApiReferenceConfiguration> & {
|
|
11
|
-
cdn?: string;
|
|
12
9
|
};
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* The custom theme CSS for the API Reference.
|
|
15
13
|
*/
|
|
16
|
-
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #
|
|
17
|
-
/**
|
|
18
|
-
* The HTML to load the @scalar/api-reference package.
|
|
19
|
-
*/
|
|
20
|
-
declare const ApiReference: (options: ApiReferenceOptions) => string;
|
|
14
|
+
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #1b1b1b;\n --scalar-color-2: #757575;\n --scalar-color-3: #8e8e8e;\n --scalar-color-accent: #e0234d;\n --scalar-background-1: #fff;\n --scalar-background-2: #f6f6f6;\n --scalar-background-3: #e7e7e7;\n --scalar-background-accent: #8ab4f81f;\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 1);\n --scalar-color-2: #b2bac2;\n --scalar-color-3: #6e748b;\n --scalar-color-accent: #e0234d;\n --scalar-background-1: #11131e;\n --scalar-background-2: #1c2132;\n --scalar-background-3: #2f354a;\n --scalar-background-accent: #8ab4f81f;\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n/* Document Sidebar */\n.light-mode .t-doc__sidebar,\n.dark-mode .t-doc__sidebar {\n --scalar-sidebar-background-1: var(--scalar-background-1);\n --scalar-sidebar-item-hover-color: currentColor;\n --scalar-sidebar-item-hover-background: var(--scalar-background-2);\n --scalar-sidebar-item-active-background: var(--scalar-background-3);\n --scalar-sidebar-border-color: var(--scalar-border-color);\n --scalar-sidebar-color-1: var(--scalar-color-1);\n --scalar-sidebar-color-2: var(--scalar-color-2);\n --scalar-sidebar-color-active: var(--scalar-color-1);\n --scalar-sidebar-search-background: var(--scalar-background-2);\n --scalar-sidebar-search-border-color: var(--scalar-background-2);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n/* advanced */\n.light-mode {\n --scalar-button-1: rgb(49 53 56);\n --scalar-button-1-color: #fff;\n --scalar-button-1-hover: rgb(28 31 33);\n --scalar-color-green: #069061;\n --scalar-color-red: #ef0006;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0082d0;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);\n --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n}\n.dark-mode {\n --scalar-button-1: #f6f6f6;\n --scalar-button-1-color: #000;\n --scalar-button-1-hover: #e7e7e7;\n --scalar-color-green: #30beb0;\n --scalar-color-red: #e91e63;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #2cb6f6;\n --scalar-color-orange: #ff5656;\n --scalar-color-purple: #6223e0;\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n";
|
|
21
15
|
/**
|
|
22
16
|
* The HTML template to render the API Reference.
|
|
23
17
|
*/
|
|
24
|
-
declare function apiReference(
|
|
18
|
+
declare function apiReference(givenConfiguration: NestJSReferenceConfiguration): ((_req: FastifyRequest, res: ServerResponse) => void) | ((_req: Request, res: Response) => void);
|
|
25
19
|
|
|
26
|
-
export {
|
|
20
|
+
export { type ApiReferenceOptions, type NestJSReferenceConfiguration, apiReference, customThemeCSS };
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/nestJSApiReference.ts
|
|
5
|
+
import { getHtmlDocument } from "@scalar/core/libs/html-rendering";
|
|
5
6
|
var customThemeCSS = `
|
|
6
7
|
/* basic theme */
|
|
7
8
|
.light-mode {
|
|
8
|
-
--scalar-color-1: #
|
|
9
|
+
--scalar-color-1: #1b1b1b;
|
|
9
10
|
--scalar-color-2: #757575;
|
|
10
11
|
--scalar-color-3: #8e8e8e;
|
|
11
12
|
--scalar-color-accent: #e0234d;
|
|
@@ -70,54 +71,30 @@ var customThemeCSS = `
|
|
|
70
71
|
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
71
72
|
}
|
|
72
73
|
`;
|
|
73
|
-
var
|
|
74
|
+
var DEFAULT_CONFIGURATION = {
|
|
75
|
+
_integration: "nestjs"
|
|
76
|
+
};
|
|
77
|
+
function apiReference(givenConfiguration) {
|
|
74
78
|
const configuration = {
|
|
75
|
-
|
|
76
|
-
...
|
|
79
|
+
...DEFAULT_CONFIGURATION,
|
|
80
|
+
...givenConfiguration
|
|
77
81
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
id="api-reference"
|
|
81
|
-
type="application/json"
|
|
82
|
-
data-configuration="${JSON.stringify(configuration).split('"').join(""")}">${configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : ""}</script>
|
|
83
|
-
<script src="${configuration.cdn || "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"></script>
|
|
84
|
-
`;
|
|
85
|
-
}, "ApiReference");
|
|
86
|
-
function apiReference(options) {
|
|
87
|
-
const content = `
|
|
88
|
-
<!DOCTYPE html>
|
|
89
|
-
<html>
|
|
90
|
-
<head>
|
|
91
|
-
<title>${options.title || "Scalar API Reference"}</title>
|
|
92
|
-
<meta charset="utf-8" />
|
|
93
|
-
<meta
|
|
94
|
-
name="viewport"
|
|
95
|
-
content="width=device-width, initial-scale=1" />
|
|
96
|
-
<style>
|
|
97
|
-
${options.theme ? null : customThemeCSS}
|
|
98
|
-
</style>
|
|
99
|
-
</head>
|
|
100
|
-
<body>
|
|
101
|
-
${ApiReference(options)}
|
|
102
|
-
</body>
|
|
103
|
-
</html>
|
|
104
|
-
`;
|
|
105
|
-
if (options.withFastify) {
|
|
82
|
+
const content = /* @__PURE__ */ __name(() => getHtmlDocument(configuration, customThemeCSS), "content");
|
|
83
|
+
if (givenConfiguration.withFastify) {
|
|
106
84
|
return (_req, res) => {
|
|
107
85
|
res.writeHead(200, {
|
|
108
86
|
"Content-Type": "text/html"
|
|
109
87
|
});
|
|
110
|
-
res.write(content);
|
|
88
|
+
res.write(content());
|
|
111
89
|
res.end();
|
|
112
90
|
};
|
|
113
91
|
}
|
|
114
92
|
return (_req, res) => {
|
|
115
|
-
res.send(content);
|
|
93
|
+
res.send(content());
|
|
116
94
|
};
|
|
117
95
|
}
|
|
118
96
|
__name(apiReference, "apiReference");
|
|
119
97
|
export {
|
|
120
|
-
ApiReference,
|
|
121
98
|
apiReference,
|
|
122
99
|
customThemeCSS
|
|
123
100
|
};
|
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.
|
|
13
|
+
"version": "1.0.0",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -34,21 +34,23 @@
|
|
|
34
34
|
],
|
|
35
35
|
"module": "dist/index.js",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@scalar/
|
|
37
|
+
"@scalar/core": "0.3.15"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@nestjs/common": "^
|
|
41
|
-
"@nestjs/
|
|
42
|
-
"@nestjs/
|
|
40
|
+
"@nestjs/common": "^11.1.6",
|
|
41
|
+
"@nestjs/core": "^11.1.6",
|
|
42
|
+
"@nestjs/platform-express": "^10.3.8",
|
|
43
|
+
"@nestjs/platform-fastify": "^11.1.6",
|
|
44
|
+
"@nestjs/testing": "^11.1.6",
|
|
43
45
|
"@types/express": "5.0.3",
|
|
44
46
|
"@types/supertest": "^2.0.12",
|
|
45
47
|
"express": "5.1.0",
|
|
46
|
-
"fastify": "^4.
|
|
47
|
-
"supertest": "^
|
|
48
|
+
"fastify": "^5.4.0",
|
|
49
|
+
"supertest": "^7.1.4",
|
|
48
50
|
"tsup": "^8.3.5",
|
|
49
51
|
"vite": "6.1.6",
|
|
50
52
|
"vitest": "^3.2.4",
|
|
51
|
-
"@scalar/api-reference": "1.
|
|
53
|
+
"@scalar/api-reference": "1.35.0"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
54
56
|
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|