@scalar/nestjs-api-reference 0.1.12 → 0.1.14
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 +30 -22
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +30 -22
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -108,29 +108,37 @@ var ApiReference = (options) => {
|
|
|
108
108
|
`;
|
|
109
109
|
};
|
|
110
110
|
function apiReference(options) {
|
|
111
|
+
const content = `
|
|
112
|
+
<!DOCTYPE html>
|
|
113
|
+
<html>
|
|
114
|
+
<head>
|
|
115
|
+
<title>API Reference</title>
|
|
116
|
+
<meta charset="utf-8" />
|
|
117
|
+
<meta
|
|
118
|
+
name="viewport"
|
|
119
|
+
content="width=device-width, initial-scale=1" />
|
|
120
|
+
<style>
|
|
121
|
+
body {
|
|
122
|
+
margin: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
${options.theme ? null : customThemeCSS}
|
|
126
|
+
</style>
|
|
127
|
+
</head>
|
|
128
|
+
<body>
|
|
129
|
+
${ApiReference(options)}
|
|
130
|
+
</body>
|
|
131
|
+
</html>
|
|
132
|
+
`;
|
|
133
|
+
if (options.withFastify) {
|
|
134
|
+
return (req, res) => {
|
|
135
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
136
|
+
res.write(content);
|
|
137
|
+
res.end();
|
|
138
|
+
};
|
|
139
|
+
}
|
|
111
140
|
return (req, res) => {
|
|
112
|
-
res.send(
|
|
113
|
-
<!DOCTYPE html>
|
|
114
|
-
<html>
|
|
115
|
-
<head>
|
|
116
|
-
<title>API Reference</title>
|
|
117
|
-
<meta charset="utf-8" />
|
|
118
|
-
<meta
|
|
119
|
-
name="viewport"
|
|
120
|
-
content="width=device-width, initial-scale=1" />
|
|
121
|
-
<style>
|
|
122
|
-
body {
|
|
123
|
-
margin: 0;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
${options.theme ? null : customThemeCSS}
|
|
127
|
-
</style>
|
|
128
|
-
</head>
|
|
129
|
-
<body>
|
|
130
|
-
${ApiReference(options)}
|
|
131
|
-
</body>
|
|
132
|
-
</html>
|
|
133
|
-
`);
|
|
141
|
+
res.send(content);
|
|
134
142
|
};
|
|
135
143
|
}
|
|
136
144
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ReferenceConfiguration } from '@scalar/api-reference';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
+
import { FastifyRequest } from 'fastify';
|
|
4
|
+
import { ServerResponse } from 'http';
|
|
3
5
|
|
|
6
|
+
type NestJSReferenceConfiguration = ReferenceConfiguration & {
|
|
7
|
+
withFastify?: boolean;
|
|
8
|
+
};
|
|
4
9
|
type ApiReferenceOptions = ReferenceConfiguration;
|
|
5
10
|
/**
|
|
6
11
|
* The custom theme CSS for the API Reference.
|
|
@@ -13,6 +18,6 @@ declare const ApiReference: (options: ApiReferenceOptions) => string;
|
|
|
13
18
|
/**
|
|
14
19
|
* The HTML template to render the API Reference.
|
|
15
20
|
*/
|
|
16
|
-
declare function apiReference(options:
|
|
21
|
+
declare function apiReference(options: NestJSReferenceConfiguration): ((req: FastifyRequest, res: ServerResponse) => void) | ((req: Request, res: Response) => void);
|
|
17
22
|
|
|
18
|
-
export { ApiReference, ApiReferenceOptions, apiReference, customThemeCSS };
|
|
23
|
+
export { ApiReference, ApiReferenceOptions, NestJSReferenceConfiguration, apiReference, customThemeCSS };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ReferenceConfiguration } from '@scalar/api-reference';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
+
import { FastifyRequest } from 'fastify';
|
|
4
|
+
import { ServerResponse } from 'http';
|
|
3
5
|
|
|
6
|
+
type NestJSReferenceConfiguration = ReferenceConfiguration & {
|
|
7
|
+
withFastify?: boolean;
|
|
8
|
+
};
|
|
4
9
|
type ApiReferenceOptions = ReferenceConfiguration;
|
|
5
10
|
/**
|
|
6
11
|
* The custom theme CSS for the API Reference.
|
|
@@ -13,6 +18,6 @@ declare const ApiReference: (options: ApiReferenceOptions) => string;
|
|
|
13
18
|
/**
|
|
14
19
|
* The HTML template to render the API Reference.
|
|
15
20
|
*/
|
|
16
|
-
declare function apiReference(options:
|
|
21
|
+
declare function apiReference(options: NestJSReferenceConfiguration): ((req: FastifyRequest, res: ServerResponse) => void) | ((req: Request, res: Response) => void);
|
|
17
22
|
|
|
18
|
-
export { ApiReference, ApiReferenceOptions, apiReference, customThemeCSS };
|
|
23
|
+
export { ApiReference, ApiReferenceOptions, NestJSReferenceConfiguration, apiReference, customThemeCSS };
|
package/dist/index.js
CHANGED
|
@@ -80,29 +80,37 @@ var ApiReference = (options) => {
|
|
|
80
80
|
`;
|
|
81
81
|
};
|
|
82
82
|
function apiReference(options) {
|
|
83
|
+
const content = `
|
|
84
|
+
<!DOCTYPE html>
|
|
85
|
+
<html>
|
|
86
|
+
<head>
|
|
87
|
+
<title>API Reference</title>
|
|
88
|
+
<meta charset="utf-8" />
|
|
89
|
+
<meta
|
|
90
|
+
name="viewport"
|
|
91
|
+
content="width=device-width, initial-scale=1" />
|
|
92
|
+
<style>
|
|
93
|
+
body {
|
|
94
|
+
margin: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
${options.theme ? null : customThemeCSS}
|
|
98
|
+
</style>
|
|
99
|
+
</head>
|
|
100
|
+
<body>
|
|
101
|
+
${ApiReference(options)}
|
|
102
|
+
</body>
|
|
103
|
+
</html>
|
|
104
|
+
`;
|
|
105
|
+
if (options.withFastify) {
|
|
106
|
+
return (req, res) => {
|
|
107
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
108
|
+
res.write(content);
|
|
109
|
+
res.end();
|
|
110
|
+
};
|
|
111
|
+
}
|
|
83
112
|
return (req, res) => {
|
|
84
|
-
res.send(
|
|
85
|
-
<!DOCTYPE html>
|
|
86
|
-
<html>
|
|
87
|
-
<head>
|
|
88
|
-
<title>API Reference</title>
|
|
89
|
-
<meta charset="utf-8" />
|
|
90
|
-
<meta
|
|
91
|
-
name="viewport"
|
|
92
|
-
content="width=device-width, initial-scale=1" />
|
|
93
|
-
<style>
|
|
94
|
-
body {
|
|
95
|
-
margin: 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
${options.theme ? null : customThemeCSS}
|
|
99
|
-
</style>
|
|
100
|
-
</head>
|
|
101
|
-
<body>
|
|
102
|
-
${ApiReference(options)}
|
|
103
|
-
</body>
|
|
104
|
-
</html>
|
|
105
|
-
`);
|
|
113
|
+
res.send(content);
|
|
106
114
|
};
|
|
107
115
|
}
|
|
108
116
|
export {
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"author": "Scalar (https://github.com/scalar)",
|
|
6
6
|
"homepage": "https://github.com/scalar/scalar",
|
|
7
7
|
"bugs": "https://github.com/scalar/scalar/issues/new/choose",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.14",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=20"
|
|
11
11
|
},
|
|
@@ -35,10 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"express": "^4.18.2",
|
|
38
|
-
"@scalar/api-reference": "1.13.
|
|
38
|
+
"@scalar/api-reference": "1.13.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/express": "^4.17.21",
|
|
42
|
+
"fastify": "^4.23.2",
|
|
42
43
|
"tsup": "^7.2.0",
|
|
43
44
|
"vite": "^4.4.12",
|
|
44
45
|
"vitest": "^0.34.4"
|