Add API authentication
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
import { swaggerUI } from "@hono/swagger-ui";
|
||||
|
||||
export function getApp() {
|
||||
return new OpenAPIHono().basePath("/api/v1");
|
||||
const app = new OpenAPIHono().basePath("/api");
|
||||
|
||||
// The OpenAPI documentation will be available at /doc
|
||||
app.doc("/v1/doc", (c) => ({
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
version: "1.0.0",
|
||||
title: "Unsend API",
|
||||
},
|
||||
servers: [{ url: `${new URL(c.req.url).origin}/api` }],
|
||||
}));
|
||||
|
||||
app.openAPIRegistry.registerComponent("securitySchemes", "Bearer", {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
});
|
||||
|
||||
app.get("/v1/ui", swaggerUI({ url: "/api/v1/doc" }));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
export type PublicAPIApp = ReturnType<typeof getApp>;
|
||||
|
Reference in New Issue
Block a user