Files changed (4) hide show
  1. README.md +1 -1
  2. app.ts +14 -7
  3. package.json +1 -1
  4. pnpm-lock.yaml +27 -40
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: OpenAPI
3
  emoji: 🦀
4
  colorFrom: blue
5
  colorTo: purple
 
1
  ---
2
+ title: Openapi
3
  emoji: 🦀
4
  colorFrom: blue
5
  colorTo: purple
app.ts CHANGED
@@ -3,17 +3,24 @@ import express from "express";
3
 
4
  const app = express();
5
 
6
- app.use("/", (req, res, next) => {
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  return apiReference({
8
  url: "https://huggingface.co/.well-known/openapi.json",
9
- title: "Hub API Endpoints",
10
- pageTitle: "Hub API Endpoints",
11
  hideClientButton: true,
12
  defaultOpenAllTags: true,
13
- onSidebarClick: (href) => {
14
- const url = new URL(href);
15
- parent.postMessage({ hash: url.hash.slice(1) }, '*');
16
- },
17
  })(req, res);
18
  });
19
 
 
3
 
4
  const app = express();
5
 
6
+ app.use("/", (req, res, next) => {
7
+ const originalSend = res.send.bind(res);
8
+ res.send = (x) =>
9
+ originalSend(
10
+ x.replace(
11
+ "</html>",
12
+ `<script>addEventListener(
13
+ 'hashchange',
14
+ event => {
15
+ parent.postMessage({hash: new URL(event.newURL).hash.slice(1)}, '*');
16
+ }
17
+ )</script></html>`
18
+ )
19
+ );
20
  return apiReference({
21
  url: "https://huggingface.co/.well-known/openapi.json",
 
 
22
  hideClientButton: true,
23
  defaultOpenAllTags: true,
 
 
 
 
24
  })(req, res);
25
  });
26
 
package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "type": "module",
3
  "dependencies": {
4
- "@scalar/express-api-reference": "^0.8.35",
5
  "express": "^5.1.0"
6
  },
7
  "devDependencies": {
 
1
  {
2
  "type": "module",
3
  "dependencies": {
4
+ "@scalar/express-api-reference": "^0.8.4",
5
  "express": "^5.1.0"
6
  },
7
  "devDependencies": {
pnpm-lock.yaml CHANGED
@@ -9,8 +9,8 @@ importers:
9
  .:
10
  dependencies:
11
  '@scalar/express-api-reference':
12
- specifier: ^0.8.35
13
- version: 0.8.35
14
  express:
15
  specifier: ^5.1.0
16
  version: 5.1.0
@@ -21,20 +21,20 @@ importers:
21
 
22
  packages:
23
 
24
- '@scalar/core@0.3.32':
25
- resolution: {integrity: sha512-5qUC2l1fhLyKw1iKAbuQCWb2TNZ4Y52MDc7MA7RA7QLdJ0QPBzk2UAJ0ZuYY2dIhZ3qTcpuqtF4EXEllXHoNOA==}
26
  engines: {node: '>=20'}
27
 
28
- '@scalar/express-api-reference@0.8.35':
29
- resolution: {integrity: sha512-4SK8oAi42FDpvR9aTz1om5yteZFTPLxVAiXLIRNsKGP1c6KPph87f489wegXov6000C7lz4nYsmXbqa/5r/M/A==}
30
  engines: {node: '>=20'}
31
 
32
- '@scalar/helpers@0.2.8':
33
- resolution: {integrity: sha512-aXXRF4sCaiGZIRpZ1MUcnl8y0Q9pPG1VXqQMWacVWDh6zQN9cuayTC/TbODzWeldp50sgJ1E8MpHvpeV7CEF9g==}
34
  engines: {node: '>=20'}
35
 
36
- '@scalar/types@0.5.8':
37
- resolution: {integrity: sha512-eL8zojDI9QB+kNRkuM80auTKHnzNrlOLC8ZLUJVnY0Jj5ZtoInKMDGodgQXK1wOSDTcfVfgLALOY1zb6cFFlCg==}
38
  engines: {node: '>=20'}
39
 
40
  '@types/body-parser@1.19.6':
@@ -229,8 +229,8 @@ packages:
229
  ms@2.1.3:
230
  resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
231
 
232
- nanoid@5.1.6:
233
- resolution: {integrity: sha512-c7+7RQ+dMB5dPwwCp4ee1/iV/q2P6aK1mTZcfr1BTuVlyW9hJYiMPybJCcnBlQtuSmTIWNeazm/zqNoZSSElBg==}
234
  engines: {node: ^18 || >=20}
235
  hasBin: true
236
 
@@ -318,18 +318,10 @@ packages:
318
  resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
319
  engines: {node: '>= 0.8'}
320
 
321
- tagged-tag@1.0.0:
322
- resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==}
323
- engines: {node: '>=20'}
324
-
325
  toidentifier@1.0.1:
326
  resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
327
  engines: {node: '>=0.6'}
328
 
329
- type-fest@5.4.1:
330
- resolution: {integrity: sha512-xygQcmneDyzsEuKZrFbRMne5HDqMs++aFzefrJTgEIKjQ3rekM+RPfFCVq2Gp1VIDqddoYeppCj4Pcb+RZW0GQ==}
331
- engines: {node: '>=20'}
332
-
333
  type-is@2.0.1:
334
  resolution: {integrity: sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==}
335
  engines: {node: '>= 0.6'}
@@ -348,27 +340,28 @@ packages:
348
  wrappy@1.0.2:
349
  resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
350
 
351
- zod@4.3.5:
352
- resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==}
353
 
354
  snapshots:
355
 
356
- '@scalar/core@0.3.32':
357
  dependencies:
358
- '@scalar/types': 0.5.8
359
 
360
- '@scalar/express-api-reference@0.8.35':
361
  dependencies:
362
- '@scalar/core': 0.3.32
363
 
364
- '@scalar/helpers@0.2.8': {}
 
 
365
 
366
- '@scalar/types@0.5.8':
367
  dependencies:
368
- '@scalar/helpers': 0.2.8
369
- nanoid: 5.1.6
370
- type-fest: 5.4.1
371
- zod: 4.3.5
372
 
373
  '@types/body-parser@1.19.6':
374
  dependencies:
@@ -591,7 +584,7 @@ snapshots:
591
 
592
  ms@2.1.3: {}
593
 
594
- nanoid@5.1.6: {}
595
 
596
  negotiator@1.0.0: {}
597
 
@@ -700,14 +693,8 @@ snapshots:
700
 
701
  statuses@2.0.2: {}
702
 
703
- tagged-tag@1.0.0: {}
704
-
705
  toidentifier@1.0.1: {}
706
 
707
- type-fest@5.4.1:
708
- dependencies:
709
- tagged-tag: 1.0.0
710
-
711
  type-is@2.0.1:
712
  dependencies:
713
  content-type: 1.0.5
@@ -722,4 +709,4 @@ snapshots:
722
 
723
  wrappy@1.0.2: {}
724
 
725
- zod@4.3.5: {}
 
9
  .:
10
  dependencies:
11
  '@scalar/express-api-reference':
12
+ specifier: ^0.8.4
13
+ version: 0.8.4
14
  express:
15
  specifier: ^5.1.0
16
  version: 5.1.0
 
21
 
22
  packages:
23
 
24
+ '@scalar/core@0.3.3':
25
+ resolution: {integrity: sha512-OedH8YQriBsE7JnCN2ly4p3u7iobjzAoDkxD/o1hiF55m6WRicvtklEdByHlceu9UnJ/znikZ50ymo98uG3aqA==}
26
  engines: {node: '>=20'}
27
 
28
+ '@scalar/express-api-reference@0.8.4':
29
+ resolution: {integrity: sha512-seQ+cHjIk1NltHLOIIVUqlvMx7TEP++KvnhX6NFjNH7/o0wor8ncRit5LsY5v9OmSHzebKWNLY+mbp8dy76kVg==}
30
  engines: {node: '>=20'}
31
 
32
+ '@scalar/openapi-types@0.3.3':
33
+ resolution: {integrity: sha512-mr3OvbCyvuzSDgv9gR9D3pJAsl82BRNBp1P8ldgRgKF4Wiswfa7nQeKibpX0kHSGXLgiyvxWJULUFwgdWMXNNA==}
34
  engines: {node: '>=20'}
35
 
36
+ '@scalar/types@0.2.3':
37
+ resolution: {integrity: sha512-K1/Vp5xaQ8TEGDYwHg88OBuQWJRWrE3ToZ0Z2LJwskcY1Eg+uDiRQXKF4QPngZzu5rrWgRErAq4yte4Y7omqgA==}
38
  engines: {node: '>=20'}
39
 
40
  '@types/body-parser@1.19.6':
 
229
  ms@2.1.3:
230
  resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
231
 
232
+ nanoid@5.1.5:
233
+ resolution: {integrity: sha512-Ir/+ZpE9fDsNH0hQ3C68uyThDXzYcim2EqcZ8zn8Chtt1iylPT9xXJB0kPCnqzgcEGikO9RxSrh63MsmVCU7Fw==}
234
  engines: {node: ^18 || >=20}
235
  hasBin: true
236
 
 
318
  resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
319
  engines: {node: '>= 0.8'}
320
 
 
 
 
 
321
  toidentifier@1.0.1:
322
  resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
323
  engines: {node: '>=0.6'}
324
 
 
 
 
 
325
  type-is@2.0.1:
326
  resolution: {integrity: sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==}
327
  engines: {node: '>= 0.6'}
 
340
  wrappy@1.0.2:
341
  resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
342
 
343
+ zod@3.24.1:
344
+ resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
345
 
346
  snapshots:
347
 
348
+ '@scalar/core@0.3.3':
349
  dependencies:
350
+ '@scalar/types': 0.2.3
351
 
352
+ '@scalar/express-api-reference@0.8.4':
353
  dependencies:
354
+ '@scalar/core': 0.3.3
355
 
356
+ '@scalar/openapi-types@0.3.3':
357
+ dependencies:
358
+ zod: 3.24.1
359
 
360
+ '@scalar/types@0.2.3':
361
  dependencies:
362
+ '@scalar/openapi-types': 0.3.3
363
+ nanoid: 5.1.5
364
+ zod: 3.24.1
 
365
 
366
  '@types/body-parser@1.19.6':
367
  dependencies:
 
584
 
585
  ms@2.1.3: {}
586
 
587
+ nanoid@5.1.5: {}
588
 
589
  negotiator@1.0.0: {}
590
 
 
693
 
694
  statuses@2.0.2: {}
695
 
 
 
696
  toidentifier@1.0.1: {}
697
 
 
 
 
 
698
  type-is@2.0.1:
699
  dependencies:
700
  content-type: 1.0.5
 
709
 
710
  wrappy@1.0.2: {}
711
 
712
+ zod@3.24.1: {}