mirror of
https://github.com/Lissy93/awesome-privacy.git
synced 2026-03-11 08:55:33 +00:00
Updates API landing for Hono on CF workers for Swagger
This commit is contained in:
parent
3e2d719d47
commit
40611ea022
3 changed files with 12 additions and 21 deletions
|
|
@ -9,34 +9,20 @@ import {
|
|||
renderRemoteIndex,
|
||||
} from './utils';
|
||||
|
||||
import index from '../public/index.html'
|
||||
|
||||
/* Create new Hono app */
|
||||
const app = new Hono<{}, {}>({ strict: false });
|
||||
const app = new Hono({ strict: false });
|
||||
|
||||
/* Serve the index page (which contains the Swagger Docs) */
|
||||
app.get("/", async (ctx) => {
|
||||
console.log('ctx.env', ctx.env);
|
||||
|
||||
if (ctx.env?.ASSETS) {
|
||||
let response: Response | undefined;
|
||||
try {
|
||||
response = await ctx.env.ASSETS.fetch(
|
||||
ctx.request.url,
|
||||
ctx.request.clone()
|
||||
);
|
||||
response =
|
||||
response && response.status >= 200 && response.status < 400
|
||||
? new Response(response.body, response)
|
||||
: undefined;
|
||||
} catch {}
|
||||
if (!response) {
|
||||
return renderRemoteIndex(ctx);
|
||||
}
|
||||
if (index) {
|
||||
return ctx.html(index)
|
||||
} else {
|
||||
return renderRemoteIndex(ctx);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Returns an array all service objects */
|
||||
app.get('/services', async (c) => {
|
||||
return c.json(await fetchAllServices());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
import api from './api';
|
||||
|
||||
api.fire();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
name = "awesome-privacy-api"
|
||||
compatibility_date = "2024-03-04"
|
||||
main = "src/index.ts"
|
||||
# node_compat = true
|
||||
|
||||
rules = [
|
||||
{ type = "Text", globs = ["public/*.html"], fallthrough = true }
|
||||
]
|
||||
|
||||
|
||||
[site]
|
||||
bucket = "./public" # Path to your static files
|
||||
|
|
|
|||
Loading…
Reference in a new issue