@scalar/express-api-reference 0.4.173 → 0.4.175
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 +2 -2
- package/dist/apiReference.d.ts +18 -0
- package/dist/apiReference.d.ts.map +1 -0
- package/dist/{index.cjs → apiReference.js} +31 -49
- package/dist/index.d.ts +2 -20
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -138
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/package.json +16 -15
- package/dist/index.d.cts +0 -20
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ npm install @scalar/express-api-reference
|
|
|
17
17
|
|
|
18
18
|
[Set up Express](https://expressjs.com/en/starter/hello-world.html) and pass an URL to an OpenAPI/Swagger document to the `apiReference` middleware:
|
|
19
19
|
|
|
20
|
-
> Wait, but how do we get the
|
|
20
|
+
> Wait, but how do we get the OpenAPI document? 🤔 There are multiple ways to generate an OpenAPI file for Express. The most popular way is to use [`swagger-jsdoc`](https://github.com/Surnet/swagger-jsdoc).
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
23
|
import { apiReference } from '@scalar/express-api-reference'
|
|
@@ -55,7 +55,7 @@ app.use(
|
|
|
55
55
|
|
|
56
56
|
### Custom CDN
|
|
57
57
|
|
|
58
|
-
You can use a custom CDN
|
|
58
|
+
You can use a custom CDN, default is `https://cdn.jsdelivr.net/npm/@scalar/api-reference`.
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
61
|
import { apiReference } from '@scalar/express-api-reference'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReferenceConfiguration } from '@scalar/types/legacy';
|
|
2
|
+
import type { Request, Response } from 'express';
|
|
3
|
+
export type ApiReferenceOptions = ReferenceConfiguration & {
|
|
4
|
+
cdn?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The custom theme CSS for the Express theme.
|
|
8
|
+
*/
|
|
9
|
+
export declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #353535;\n --scalar-color-2: #555555;\n --scalar-color-3: #aeaeae;\n --scalar-color-accent: #259dff;\n\n --scalar-background-1: #fff;\n --scalar-background-2: #f7f7f7;\n --scalar-background-3: #dadada;\n --scalar-background-accent: #E0F5FF;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 0.9);\n --scalar-color-2: rgba(255, 255, 255, 0.62);\n --scalar-color-3: rgba(255, 255, 255, 0.44);\n --scalar-color-accent: #8ab4f8;\n\n --scalar-background-1: #1a1a1a;\n --scalar-background-2: #252525;\n --scalar-background-3: #323232;\n --scalar-background-accent: #8ab4f81f;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n\n/* Document Sidebar */\n.light-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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n.dark-mode .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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\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\n --scalar-color-green: #669900;\n --scalar-color-red: #dc4a68;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0277aa;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n\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\n --scalar-color-green: #00b648;\n --scalar-color-red: #dc1b19;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #4eb3ec;\n --scalar-color-orange: #ff8d4d;\n --scalar-color-purple: #b191f9;\n\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n:root {\n --scalar-radius: 3px;\n --scalar-radius-lg: 3px;\n --scalar-radius-xl: 3px;\n}\n";
|
|
10
|
+
/**
|
|
11
|
+
* The script tags to load the @scalar/api-reference package from the CDN.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getScriptTags: (configuration: ApiReferenceOptions) => string;
|
|
14
|
+
/**
|
|
15
|
+
* The route handler to render the API Reference.
|
|
16
|
+
*/
|
|
17
|
+
export declare function apiReference(options: ApiReferenceOptions): (req: Request, res: Response) => void;
|
|
18
|
+
//# sourceMappingURL=apiReference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiReference.d.ts","sourceRoot":"","sources":["../src/apiReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEhD,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,mnGA8F1B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,kBAAmB,mBAAmB,WAuB/D,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,SAC1C,OAAO,OAAO,QAAQ,UAoBpC"}
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
ApiReference: () => ApiReference,
|
|
24
|
-
apiReference: () => apiReference,
|
|
25
|
-
customThemeCSS: () => customThemeCSS
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
|
|
29
|
-
// src/expressApiReference.ts
|
|
30
|
-
var customThemeCSS = `
|
|
1
|
+
/**
|
|
2
|
+
* The custom theme CSS for the Express theme.
|
|
3
|
+
*/
|
|
4
|
+
const customThemeCSS = `
|
|
31
5
|
/* basic theme */
|
|
32
6
|
.light-mode {
|
|
33
7
|
--scalar-color-1: #353535;
|
|
@@ -122,24 +96,36 @@ var customThemeCSS = `
|
|
|
122
96
|
--scalar-radius-xl: 3px;
|
|
123
97
|
}
|
|
124
98
|
`;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The script tags to load the @scalar/api-reference package from the CDN.
|
|
101
|
+
*/
|
|
102
|
+
const getScriptTags = (configuration) => {
|
|
103
|
+
const defaultConfiguration = {
|
|
104
|
+
_integration: 'express',
|
|
105
|
+
};
|
|
106
|
+
return `
|
|
130
107
|
<script
|
|
131
108
|
id="api-reference"
|
|
132
109
|
type="application/json"
|
|
133
110
|
data-configuration="${JSON.stringify({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
111
|
+
...defaultConfiguration,
|
|
112
|
+
...configuration,
|
|
113
|
+
})
|
|
114
|
+
.split('"')
|
|
115
|
+
.join('"')}">${configuration.spec?.content
|
|
116
|
+
? typeof configuration.spec?.content === 'function'
|
|
117
|
+
? JSON.stringify(configuration.spec?.content())
|
|
118
|
+
: JSON.stringify(configuration.spec?.content)
|
|
119
|
+
: ''}</script>
|
|
120
|
+
<script src="${configuration.cdn || 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'}"></script>
|
|
138
121
|
`;
|
|
139
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* The route handler to render the API Reference.
|
|
125
|
+
*/
|
|
140
126
|
function apiReference(options) {
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
return (req, res) => {
|
|
128
|
+
res.type('text/html').send(`
|
|
143
129
|
<!DOCTYPE html>
|
|
144
130
|
<html>
|
|
145
131
|
<head>
|
|
@@ -153,15 +139,11 @@ function apiReference(options) {
|
|
|
153
139
|
</style>
|
|
154
140
|
</head>
|
|
155
141
|
<body>
|
|
156
|
-
${
|
|
142
|
+
${getScriptTags(options)}
|
|
157
143
|
</body>
|
|
158
144
|
</html>
|
|
159
145
|
`);
|
|
160
|
-
|
|
146
|
+
};
|
|
161
147
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
ApiReference,
|
|
165
|
-
apiReference,
|
|
166
|
-
customThemeCSS
|
|
167
|
-
});
|
|
148
|
+
|
|
149
|
+
export { apiReference, customThemeCSS, getScriptTags };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ApiReferenceOptions = ReferenceConfiguration & {
|
|
5
|
-
cdn?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* The custom theme CSS for the API Reference.
|
|
9
|
-
*/
|
|
10
|
-
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #353535;\n --scalar-color-2: #555555;\n --scalar-color-3: #aeaeae;\n --scalar-color-accent: #259dff;\n\n --scalar-background-1: #fff;\n --scalar-background-2: #f7f7f7;\n --scalar-background-3: #dadada;\n --scalar-background-accent: #E0F5FF;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 0.9);\n --scalar-color-2: rgba(255, 255, 255, 0.62);\n --scalar-color-3: rgba(255, 255, 255, 0.44);\n --scalar-color-accent: #8ab4f8;\n\n --scalar-background-1: #1a1a1a;\n --scalar-background-2: #252525;\n --scalar-background-3: #323232;\n --scalar-background-accent: #8ab4f81f;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n\n/* Document Sidebar */\n.light-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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n.dark-mode .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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\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\n --scalar-color-green: #669900;\n --scalar-color-red: #dc4a68;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0277aa;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n\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\n --scalar-color-green: #00b648;\n --scalar-color-red: #dc1b19;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #4eb3ec;\n --scalar-color-orange: #ff8d4d;\n --scalar-color-purple: #b191f9;\n\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n:root {\n --scalar-radius: 3px;\n --scalar-radius-lg: 3px;\n --scalar-radius-xl: 3px;\n}\n";
|
|
11
|
-
/**
|
|
12
|
-
* The HTML to load the @scalar/api-reference package.
|
|
13
|
-
*/
|
|
14
|
-
declare const ApiReference: (configuration: ApiReferenceOptions) => string;
|
|
15
|
-
/**
|
|
16
|
-
* The HTML template to render the API Reference.
|
|
17
|
-
*/
|
|
18
|
-
declare function apiReference(options: ApiReferenceOptions): (req: Request, res: Response) => void;
|
|
19
|
-
|
|
20
|
-
export { ApiReference, type ApiReferenceOptions, apiReference, customThemeCSS };
|
|
1
|
+
export * from './apiReference.js';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,138 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var customThemeCSS = `
|
|
3
|
-
/* basic theme */
|
|
4
|
-
.light-mode {
|
|
5
|
-
--scalar-color-1: #353535;
|
|
6
|
-
--scalar-color-2: #555555;
|
|
7
|
-
--scalar-color-3: #aeaeae;
|
|
8
|
-
--scalar-color-accent: #259dff;
|
|
9
|
-
|
|
10
|
-
--scalar-background-1: #fff;
|
|
11
|
-
--scalar-background-2: #f7f7f7;
|
|
12
|
-
--scalar-background-3: #dadada;
|
|
13
|
-
--scalar-background-accent: #E0F5FF;
|
|
14
|
-
|
|
15
|
-
--scalar-border-color: rgba(0, 0, 0, 0.1);
|
|
16
|
-
}
|
|
17
|
-
.dark-mode {
|
|
18
|
-
--scalar-color-1: rgba(255, 255, 255, 0.9);
|
|
19
|
-
--scalar-color-2: rgba(255, 255, 255, 0.62);
|
|
20
|
-
--scalar-color-3: rgba(255, 255, 255, 0.44);
|
|
21
|
-
--scalar-color-accent: #8ab4f8;
|
|
22
|
-
|
|
23
|
-
--scalar-background-1: #1a1a1a;
|
|
24
|
-
--scalar-background-2: #252525;
|
|
25
|
-
--scalar-background-3: #323232;
|
|
26
|
-
--scalar-background-accent: #8ab4f81f;
|
|
27
|
-
|
|
28
|
-
--scalar-border-color: rgba(255, 255, 255, 0.1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Document Sidebar */
|
|
32
|
-
.light-mode .t-doc__sidebar {
|
|
33
|
-
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
34
|
-
--scalar-sidebar-item-hover-color: currentColor;
|
|
35
|
-
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
36
|
-
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
37
|
-
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
38
|
-
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
39
|
-
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
40
|
-
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
41
|
-
--scalar-sidebar-search-background: transparent;
|
|
42
|
-
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
43
|
-
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.dark-mode .sidebar {
|
|
47
|
-
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
48
|
-
--scalar-sidebar-item-hover-color: currentColor;
|
|
49
|
-
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
50
|
-
--scalar-sidebar-item-active-background: var(--scalar-background-accent);
|
|
51
|
-
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
52
|
-
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
53
|
-
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
54
|
-
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
55
|
-
--scalar-sidebar-search-background: transparent;
|
|
56
|
-
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
57
|
-
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* advanced */
|
|
61
|
-
.light-mode {
|
|
62
|
-
--scalar-button-1: rgb(49 53 56);
|
|
63
|
-
--scalar-button-1-color: #fff;
|
|
64
|
-
--scalar-button-1-hover: rgb(28 31 33);
|
|
65
|
-
|
|
66
|
-
--scalar-color-green: #669900;
|
|
67
|
-
--scalar-color-red: #dc4a68;
|
|
68
|
-
--scalar-color-yellow: #edbe20;
|
|
69
|
-
--scalar-color-blue: #0277aa;
|
|
70
|
-
--scalar-color-orange: #fb892c;
|
|
71
|
-
--scalar-color-purple: #5203d1;
|
|
72
|
-
|
|
73
|
-
--scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
|
|
74
|
-
--scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
|
|
75
|
-
}
|
|
76
|
-
.dark-mode {
|
|
77
|
-
--scalar-button-1: #f6f6f6;
|
|
78
|
-
--scalar-button-1-color: #000;
|
|
79
|
-
--scalar-button-1-hover: #e7e7e7;
|
|
80
|
-
|
|
81
|
-
--scalar-color-green: #00b648;
|
|
82
|
-
--scalar-color-red: #dc1b19;
|
|
83
|
-
--scalar-color-yellow: #ffc90d;
|
|
84
|
-
--scalar-color-blue: #4eb3ec;
|
|
85
|
-
--scalar-color-orange: #ff8d4d;
|
|
86
|
-
--scalar-color-purple: #b191f9;
|
|
87
|
-
|
|
88
|
-
--scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
|
|
89
|
-
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
90
|
-
}
|
|
91
|
-
:root {
|
|
92
|
-
--scalar-radius: 3px;
|
|
93
|
-
--scalar-radius-lg: 3px;
|
|
94
|
-
--scalar-radius-xl: 3px;
|
|
95
|
-
}
|
|
96
|
-
`;
|
|
97
|
-
var ApiReference = (configuration) => {
|
|
98
|
-
const defaultConfiguration = {
|
|
99
|
-
_integration: "express"
|
|
100
|
-
};
|
|
101
|
-
return `
|
|
102
|
-
<script
|
|
103
|
-
id="api-reference"
|
|
104
|
-
type="application/json"
|
|
105
|
-
data-configuration="${JSON.stringify({
|
|
106
|
-
...defaultConfiguration,
|
|
107
|
-
...configuration
|
|
108
|
-
}).split('"').join(""")}">${configuration.spec?.content ? typeof configuration.spec?.content === "function" ? JSON.stringify(configuration.spec?.content()) : JSON.stringify(configuration.spec?.content) : ""}</script>
|
|
109
|
-
<script src="${configuration.cdn || "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"></script>
|
|
110
|
-
`;
|
|
111
|
-
};
|
|
112
|
-
function apiReference(options) {
|
|
113
|
-
return (req, res) => {
|
|
114
|
-
res.type("text/html").send(`
|
|
115
|
-
<!DOCTYPE html>
|
|
116
|
-
<html>
|
|
117
|
-
<head>
|
|
118
|
-
<title>Scalar API Reference</title>
|
|
119
|
-
<meta charset="utf-8" />
|
|
120
|
-
<meta
|
|
121
|
-
name="viewport"
|
|
122
|
-
content="width=device-width, initial-scale=1" />
|
|
123
|
-
<style>
|
|
124
|
-
${options.theme ? null : customThemeCSS}
|
|
125
|
-
</style>
|
|
126
|
-
</head>
|
|
127
|
-
<body>
|
|
128
|
-
${ApiReference(options)}
|
|
129
|
-
</body>
|
|
130
|
-
</html>
|
|
131
|
-
`);
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
ApiReference,
|
|
136
|
-
apiReference,
|
|
137
|
-
customThemeCSS
|
|
138
|
-
};
|
|
1
|
+
export { apiReference, customThemeCSS, getScriptTags } from './apiReference.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/express-api-reference"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.4.
|
|
13
|
+
"version": "0.4.175",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=18"
|
|
16
16
|
},
|
|
@@ -19,14 +19,9 @@
|
|
|
19
19
|
"types": "dist/index.d.cts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"import":
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
"require": {
|
|
27
|
-
"types": "./dist/index.d.cts",
|
|
28
|
-
"default": "./dist/index.cjs"
|
|
29
|
-
}
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
30
25
|
}
|
|
31
26
|
},
|
|
32
27
|
"files": [
|
|
@@ -34,21 +29,27 @@
|
|
|
34
29
|
],
|
|
35
30
|
"module": "dist/index.js",
|
|
36
31
|
"dependencies": {
|
|
37
|
-
"@scalar/types": "0.0.
|
|
32
|
+
"@scalar/types": "0.0.27"
|
|
38
33
|
},
|
|
39
34
|
"devDependencies": {
|
|
40
35
|
"@types/express": "^4.17.21",
|
|
36
|
+
"@types/supertest": "^2.0.12",
|
|
41
37
|
"express": "^4.21.1",
|
|
42
|
-
"
|
|
43
|
-
"vite": "^5.4.10",
|
|
38
|
+
"supertest": "^6.3.3",
|
|
44
39
|
"vitest": "^1.6.0",
|
|
45
|
-
"@scalar/api-reference": "1.25.
|
|
40
|
+
"@scalar/api-reference": "1.25.106",
|
|
41
|
+
"@scalar/build-tooling": "0.1.12"
|
|
46
42
|
},
|
|
47
43
|
"scripts": {
|
|
48
|
-
"build": "
|
|
44
|
+
"build": "scalar-build-rollup",
|
|
45
|
+
"build:playground": "cd playground && pnpm build",
|
|
46
|
+
"dev": "cd playground && pnpm dev",
|
|
47
|
+
"docker:build": "docker build --build-arg BASE_IMAGE=scalar-base -t express-api-reference -f Dockerfile .",
|
|
48
|
+
"docker:run": "docker run -p 5055:5055 express-api-reference",
|
|
49
49
|
"lint:check": "eslint .",
|
|
50
50
|
"lint:fix": "eslint . --fix",
|
|
51
51
|
"test": "vitest run",
|
|
52
|
-
"types:
|
|
52
|
+
"types:build": "scalar-types-build",
|
|
53
|
+
"types:check": "scalar-types-check"
|
|
53
54
|
}
|
|
54
55
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ReferenceConfiguration } from '@scalar/types/legacy';
|
|
2
|
-
import { Request, Response } from 'express';
|
|
3
|
-
|
|
4
|
-
type ApiReferenceOptions = ReferenceConfiguration & {
|
|
5
|
-
cdn?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* The custom theme CSS for the API Reference.
|
|
9
|
-
*/
|
|
10
|
-
declare const customThemeCSS = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #353535;\n --scalar-color-2: #555555;\n --scalar-color-3: #aeaeae;\n --scalar-color-accent: #259dff;\n\n --scalar-background-1: #fff;\n --scalar-background-2: #f7f7f7;\n --scalar-background-3: #dadada;\n --scalar-background-accent: #E0F5FF;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 0.9);\n --scalar-color-2: rgba(255, 255, 255, 0.62);\n --scalar-color-3: rgba(255, 255, 255, 0.44);\n --scalar-color-accent: #8ab4f8;\n\n --scalar-background-1: #1a1a1a;\n --scalar-background-2: #252525;\n --scalar-background-3: #323232;\n --scalar-background-accent: #8ab4f81f;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n\n/* Document Sidebar */\n.light-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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n.dark-mode .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-accent);\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-accent);\n --scalar-sidebar-search-background: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\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\n --scalar-color-green: #669900;\n --scalar-color-red: #dc4a68;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0277aa;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n\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\n --scalar-color-green: #00b648;\n --scalar-color-red: #dc1b19;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #4eb3ec;\n --scalar-color-orange: #ff8d4d;\n --scalar-color-purple: #b191f9;\n\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n:root {\n --scalar-radius: 3px;\n --scalar-radius-lg: 3px;\n --scalar-radius-xl: 3px;\n}\n";
|
|
11
|
-
/**
|
|
12
|
-
* The HTML to load the @scalar/api-reference package.
|
|
13
|
-
*/
|
|
14
|
-
declare const ApiReference: (configuration: ApiReferenceOptions) => string;
|
|
15
|
-
/**
|
|
16
|
-
* The HTML template to render the API Reference.
|
|
17
|
-
*/
|
|
18
|
-
declare function apiReference(options: ApiReferenceOptions): (req: Request, res: Response) => void;
|
|
19
|
-
|
|
20
|
-
export { ApiReference, type ApiReferenceOptions, apiReference, customThemeCSS };
|