* Add self host setup * Improve blunders * Move to bull mq * More changes * Add example code for sending test emails
32 lines
760 B
TypeScript
32 lines
760 B
TypeScript
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
import { handleError } from "./api-error";
|
|
import { env } from "~/env";
|
|
|
|
export function getApp() {
|
|
const app = new OpenAPIHono().basePath("/api");
|
|
|
|
app.onError(handleError);
|
|
|
|
// 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: `${env.NEXTAUTH_URL}/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>;
|