openapi / app.ts
Sylvestre's picture
Sylvestre HF Staff
fix: iframe protocol binding
7c842da
import { apiReference } from "@scalar/express-api-reference";
import express from "express";
const app = express();
app.use("/", (req, res, next) => {
return apiReference({
url: "https://huggingface.co/.well-known/openapi.json",
title: "Hub API Endpoints",
pageTitle: "Hub API Endpoints",
hideClientButton: true,
defaultOpenAllTags: true,
onSidebarClick: (href) => {
const url = new URL(href);
parent.postMessage({ hash: url.hash.slice(1) }, '*');
},
})(req, res);
});
const port = 7860;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});