@scalar/hono-api-reference 0.7.4 → 0.8.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/README.md CHANGED
@@ -17,17 +17,18 @@ npm install @scalar/hono-api-reference
17
17
 
18
18
  ## Usage
19
19
 
20
- Set up [Zod OpenAPI Hono](https://github.com/honojs/middleware/tree/main/packages/zod-openapi) and pass the configured URL to the `apiReference` middleware:
20
+ Set up [Zod OpenAPI Hono](https://github.com/honojs/middleware/tree/main/packages/zod-openapi) and pass the configured URL to the `Scalar` middleware:
21
21
 
22
22
  ```ts
23
- import { apiReference } from '@scalar/hono-api-reference'
24
-
25
- app.get(
26
- '/reference',
27
- apiReference({
28
- url: '/openapi.json',
29
- }),
30
- )
23
+ import { Hono } from 'hono'
24
+ import { Scalar } from '@scalar/hono-api-reference'
25
+
26
+ const app = new Hono()
27
+
28
+ // Use the middleware to serve the Scalar API Reference at /scalar
29
+ app.get('/scalar', Scalar({ url: '/doc' }))
30
+
31
+ export default app
31
32
  ```
32
33
 
33
34
  The Hono middleware takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/blob/main/documentation/configuration.md) in the core package README.
@@ -37,15 +38,13 @@ The Hono middleware takes our universal configuration object, [read more about c
37
38
  The middleware comes with a custom theme for Hono. 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.
38
39
 
39
40
  ```ts
40
- import { apiReference } from '@scalar/hono-api-reference'
41
-
42
- app.get(
43
- '/reference',
44
- apiReference({
45
- theme: 'purple',
46
- url: '/openapi.json',
47
- }),
48
- )
41
+ import { Scalar } from '@scalar/hono-api-reference'
42
+
43
+ // Switch the theme (or pass other options)
44
+ app.get('/scalar', Scalar({
45
+ url: '/doc',
46
+ theme: 'purple',
47
+ }))
49
48
  ```
50
49
 
51
50
  ### Custom page title
@@ -53,15 +52,13 @@ app.get(
53
52
  There’s one additional option to set the page title:
54
53
 
55
54
  ```ts
56
- import { apiReference } from '@scalar/hono-api-reference'
57
-
58
- app.get(
59
- '/reference',
60
- apiReference({
61
- pageTitle: 'Hono API Reference',
62
- url: '/openapi.json',
63
- }),
64
- )
55
+ import { Scalar } from '@scalar/hono-api-reference'
56
+
57
+ // Set a page title
58
+ app.get('/scalar', Scalar({
59
+ url: '/doc',
60
+ pageTitle: 'Awesome API',
61
+ }))
65
62
  ```
66
63
 
67
64
  ### Custom CDN
@@ -73,15 +70,14 @@ You can also pin the CDN to a specific version by specifying it in the CDN strin
73
70
  You can find all available CDN versions [here](https://www.jsdelivr.com/package/npm/@scalar/api-reference?tab=files)
74
71
 
75
72
  ```ts
76
- import { apiReference } from '@scalar/hono-api-reference'
77
-
78
- app.use(
79
- '/reference',
80
- apiReference({
81
- cdn: 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@latest',
82
- url: '/openapi.json',
83
- }),
84
- )
73
+ import { Scalar } from '@scalar/hono-api-reference'
74
+
75
+ app.get('/scalar', Scalar({ url: '/doc', pageTitle: 'Awesome API' }))
76
+
77
+ app.get('/scalar', Scalar({
78
+ url: '/doc',
79
+ cdn: 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@latest',
80
+ }))
85
81
  ```
86
82
 
87
83
  ## Community
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { apiReference } from './honoApiReference.ts';
1
+ export { apiReference, Scalar } from './scalar.ts';
2
2
  export type { ApiReferenceConfiguration } from './types.ts';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { apiReference } from './honoApiReference.js';
1
+ export { Scalar, apiReference } from './scalar.js';
@@ -7,5 +7,9 @@ export declare const customTheme = "\n.light-mode {\n color-scheme: light;\n -
7
7
  /**
8
8
  * The Hono middleware for the Scalar API Reference.
9
9
  */
10
+ export declare const Scalar: <E extends Env>(givenConfiguration: Partial<ApiReferenceConfiguration>) => MiddlewareHandler<E>;
11
+ /**
12
+ * @deprecated Use `Scalar` instead.
13
+ */
10
14
  export declare const apiReference: <E extends Env>(givenConfiguration: Partial<ApiReferenceConfiguration>) => MiddlewareHandler<E>;
11
- //# sourceMappingURL=honoApiReference.d.ts.map
15
+ //# sourceMappingURL=scalar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../src/scalar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAS3D;;GAEG;AACH,eAAO,MAAM,WAAW,mtHAoGvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,GAAG,sBAAsB,OAAO,CAAC,yBAAyB,CAAC,KAAG,iBAAiB,CAAC,CAAC,CASjH,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAdF,CAAC,SAAS,GAAG,sBAAsB,OAAO,CAAC,yBAAyB,CAAC,KAAG,iBAAiB,CAAC,CAAC,CAchF,CAAA"}
@@ -113,7 +113,7 @@ const customTheme = `
113
113
  /**
114
114
  * The Hono middleware for the Scalar API Reference.
115
115
  */
116
- const apiReference = (givenConfiguration) => {
116
+ const Scalar = (givenConfiguration) => {
117
117
  // Merge the defaults
118
118
  const configuration = {
119
119
  ...DEFAULT_CONFIGURATION,
@@ -122,5 +122,9 @@ const apiReference = (givenConfiguration) => {
122
122
  // Respond with the HTML document
123
123
  return async (c) => c.html(/* html */ `${getHtmlDocument(configuration, customTheme)}`);
124
124
  };
125
+ /**
126
+ * @deprecated Use `Scalar` instead.
127
+ */
128
+ const apiReference = Scalar;
125
129
 
126
- export { apiReference, customTheme };
130
+ export { Scalar, apiReference, customTheme };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scalar.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar.test.d.ts","sourceRoot":"","sources":["../src/scalar.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": "integrations/hono"
12
12
  },
13
- "version": "0.7.4",
13
+ "version": "0.8.0",
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/core": "0.2.4"
32
+ "@scalar/core": "0.2.6"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@hono/node-server": "^1.11.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"honoApiReference.d.ts","sourceRoot":"","sources":["../src/honoApiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAS3D;;GAEG;AACH,eAAO,MAAM,WAAW,mtHAoGvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,GAAG,sBACpB,OAAO,CAAC,yBAAyB,CAAC,KACrD,iBAAiB,CAAC,CAAC,CASrB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=honoApiReference.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"honoApiReference.test.d.ts","sourceRoot":"","sources":["../src/honoApiReference.test.ts"],"names":[],"mappings":""}