@scalar/express-api-reference 0.4.181 → 0.4.182

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,18 +1,11 @@
1
- import type { ReferenceConfiguration } from '@scalar/types/legacy';
1
+ import type { ApiReferenceOptions } from './types';
2
2
  import type { Request, Response } from 'express';
3
- export type ApiReferenceOptions = ReferenceConfiguration & {
4
- cdn?: string;
5
- };
6
3
  /**
7
4
  * The custom theme CSS for the Express theme.
8
5
  */
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;
6
+ export declare const customTheme = "\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";
14
7
  /**
15
8
  * The route handler to render the API Reference.
16
9
  */
17
- export declare function apiReference(options: ApiReferenceOptions): (req: Request, res: Response) => void;
10
+ export declare function apiReference(options: ApiReferenceOptions): (_: Request, res: Response) => void;
18
11
  //# sourceMappingURL=apiReference.d.ts.map
@@ -1 +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
+ {"version":3,"file":"apiReference.d.ts","sourceRoot":"","sources":["../src/apiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,mnGA8FvB,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,OAC5C,OAAO,OAAO,QAAQ,UAGlC"}
@@ -1,7 +1,9 @@
1
+ import { getHtmlDocument } from './lib/static-rendering.js';
2
+
1
3
  /**
2
4
  * The custom theme CSS for the Express theme.
3
5
  */
4
- const customThemeCSS = `
6
+ const customTheme = `
5
7
  /* basic theme */
6
8
  .light-mode {
7
9
  --scalar-color-1: #353535;
@@ -96,54 +98,13 @@ const customThemeCSS = `
96
98
  --scalar-radius-xl: 3px;
97
99
  }
98
100
  `;
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 `
107
- <script
108
- id="api-reference"
109
- type="application/json"
110
- data-configuration="${JSON.stringify({
111
- ...defaultConfiguration,
112
- ...configuration,
113
- })
114
- .split('"')
115
- .join('&quot;')}">${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>
121
- `;
122
- };
123
101
  /**
124
102
  * The route handler to render the API Reference.
125
103
  */
126
104
  function apiReference(options) {
127
- return (req, res) => {
128
- res.type('text/html').send(`
129
- <!DOCTYPE html>
130
- <html>
131
- <head>
132
- <title>Scalar API Reference</title>
133
- <meta charset="utf-8" />
134
- <meta
135
- name="viewport"
136
- content="width=device-width, initial-scale=1" />
137
- <style>
138
- ${options.theme ? null : customThemeCSS}
139
- </style>
140
- </head>
141
- <body>
142
- ${getScriptTags(options)}
143
- </body>
144
- </html>
145
- `);
105
+ return (_, res) => {
106
+ res.type('text/html').send(getHtmlDocument(options, customTheme));
146
107
  };
147
108
  }
148
109
 
149
- export { apiReference, customThemeCSS, getScriptTags };
110
+ export { apiReference, customTheme };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=apiReference.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiReference.test.d.ts","sourceRoot":"","sources":["../src/apiReference.test.ts"],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { apiReference, customThemeCSS, getScriptTags } from './apiReference.js';
1
+ export { apiReference, customTheme } from './apiReference.js';
@@ -0,0 +1,22 @@
1
+ import type { ApiReferenceOptions } from '../types';
2
+ /**
3
+ * The HTML document to render the Scalar API reference.
4
+ */
5
+ export declare function getHtmlDocument(options: ApiReferenceOptions, customTheme?: string): string;
6
+ /**
7
+ * The script tags to load the @scalar/api-reference package from the CDN.
8
+ */
9
+ export declare function getScriptTags(configuration: ApiReferenceOptions): string;
10
+ /**
11
+ * The configuration to pass to the @scalar/api-reference package.
12
+ */
13
+ export declare function getConfiguration(givenConfiguration: ApiReferenceOptions): string;
14
+ /**
15
+ * The content to pass to the @scalar/api-reference package as the <script> tag content.
16
+ */
17
+ export declare function getScriptTagContent(configuration: ApiReferenceOptions): string;
18
+ /**
19
+ * The CDN URL to load the @scalar/api-reference package from.
20
+ */
21
+ export declare function getCdnUrl(configuration: ApiReferenceOptions): string;
22
+ //# sourceMappingURL=static-rendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-rendering.d.ts","sourceRoot":"","sources":["../../src/lib/static-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAOlD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,WAAW,CAAC,EAAE,MAAM,UAmBjF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,mBAAmB,UAQ/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,UAavE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,UAMrE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,mBAAmB,UAE3D"}
@@ -0,0 +1,72 @@
1
+ const DEFAULT_CONFIGURATION = {
2
+ _integration: 'express',
3
+ };
4
+ /**
5
+ * The HTML document to render the Scalar API reference.
6
+ */
7
+ function getHtmlDocument(options, customTheme) {
8
+ return `
9
+ <!DOCTYPE html>
10
+ <html>
11
+ <head>
12
+ <title>Scalar API Reference</title>
13
+ <meta charset="utf-8" />
14
+ <meta
15
+ name="viewport"
16
+ content="width=device-width, initial-scale=1" />
17
+ <style>
18
+ ${options.theme ? null : (customTheme)}
19
+ </style>
20
+ </head>
21
+ <body>
22
+ ${getScriptTags(options)}
23
+ </body>
24
+ </html>
25
+ `;
26
+ }
27
+ /**
28
+ * The script tags to load the @scalar/api-reference package from the CDN.
29
+ */
30
+ function getScriptTags(configuration) {
31
+ return `
32
+ <script
33
+ id="api-reference"
34
+ type="application/json"
35
+ data-configuration="${getConfiguration(configuration)}">${getScriptTagContent(configuration)}</script>
36
+ <script src="${getCdnUrl(configuration)}"></script>
37
+ `;
38
+ }
39
+ /**
40
+ * The configuration to pass to the @scalar/api-reference package.
41
+ */
42
+ function getConfiguration(givenConfiguration) {
43
+ const configuration = {
44
+ ...DEFAULT_CONFIGURATION,
45
+ ...givenConfiguration,
46
+ };
47
+ if (!configuration.spec?.url) {
48
+ delete configuration.spec;
49
+ }
50
+ else if (configuration.spec?.content) {
51
+ delete configuration.spec?.content;
52
+ }
53
+ return JSON.stringify(configuration).split('"').join('&quot;');
54
+ }
55
+ /**
56
+ * The content to pass to the @scalar/api-reference package as the <script> tag content.
57
+ */
58
+ function getScriptTagContent(configuration) {
59
+ return configuration.spec?.content
60
+ ? typeof configuration.spec?.content === 'function'
61
+ ? JSON.stringify(configuration.spec?.content())
62
+ : JSON.stringify(configuration.spec?.content)
63
+ : '';
64
+ }
65
+ /**
66
+ * The CDN URL to load the @scalar/api-reference package from.
67
+ */
68
+ function getCdnUrl(configuration) {
69
+ return configuration.cdn || 'https://cdn.jsdelivr.net/npm/@scalar/api-reference';
70
+ }
71
+
72
+ export { getCdnUrl, getConfiguration, getHtmlDocument, getScriptTagContent, getScriptTags };
@@ -0,0 +1,5 @@
1
+ import type { ReferenceConfiguration } from '@scalar/types/legacy';
2
+ export type ApiReferenceOptions = ReferenceConfiguration & {
3
+ cdn?: string;
4
+ };
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "integrations/express"
12
12
  },
13
- "version": "0.4.181",
13
+ "version": "0.4.182",
14
14
  "engines": {
15
15
  "node": ">=18"
16
16
  },
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "module": "dist/index.js",
31
31
  "dependencies": {
32
- "@scalar/types": "0.0.32"
32
+ "@scalar/types": "0.0.33"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/express": "^4.17.21",
@@ -37,8 +37,8 @@
37
37
  "express": "^4.21.2",
38
38
  "supertest": "^6.3.3",
39
39
  "vitest": "^1.6.0",
40
- "@scalar/build-tooling": "0.1.12",
41
- "@scalar/api-reference": "1.25.118"
40
+ "@scalar/api-reference": "1.25.119",
41
+ "@scalar/build-tooling": "0.1.13"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "scalar-build-rollup",
@@ -46,9 +46,11 @@
46
46
  "dev": "cd playground && pnpm dev",
47
47
  "docker:build": "docker build --build-arg BASE_IMAGE=scalar-base -t express-api-reference -f Dockerfile .",
48
48
  "docker:run": "docker run -p 5055:5055 express-api-reference",
49
- "lint:check": "eslint .",
50
- "lint:fix": "eslint . --fix",
51
- "test": "vitest run",
49
+ "format:check": "scalar-format-check",
50
+ "format": "scalar-format",
51
+ "lint:check": "scalar-lint-check",
52
+ "lint:fix": "scalar-lint-fix",
53
+ "test": "vitest",
52
54
  "types:build": "scalar-types-build",
53
55
  "types:check": "scalar-types-check"
54
56
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}