openapi / app.ts
coyotte508
add logging
cd56833
raw
history blame
730 Bytes
import { apiReference } from "@scalar/express-api-reference";
import express from "express";
const app = express();
app.use("/", (req, res, next) => {
const originalSend = res.send.bind(res);
res.send = (x) =>
originalSend(
x.replace(
"</html>",
`<script>addEventListener(
'hashchange',
event => {
console.log(event, event.newURL);
parent.postMessage({data: {hash: event.newURL.hash.slice(1)}});
}
)</script></html>`
)
);
return apiReference({
url: "https://huggingface.co/.well-known/openapi.json",
hideClientButton: true,
defaultOpenAllTags: true,
})(req, res);
});
const port = 7860;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});