diff --git a/api/src/api.ts b/api/src/api.ts index 75abe2e..0222d07 100644 --- a/api/src/api.ts +++ b/api/src/api.ts @@ -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()); diff --git a/api/src/index.ts b/api/src/index.ts index 6f03fba..12a65d1 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -1,3 +1,4 @@ + import api from './api'; api.fire(); diff --git a/api/wrangler.toml b/api/wrangler.toml index 87133fa..c93742b 100644 --- a/api/wrangler.toml +++ b/api/wrangler.toml @@ -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