feat: implement openapi (#482)

This commit is contained in:
Manuel
2024-08-25 18:03:32 +02:00
committed by GitHub
parent a3520e4dfd
commit f0cd45c813
17 changed files with 14986 additions and 637 deletions

View File

@@ -0,0 +1,14 @@
import { createOpenApiFetchHandler } from "trpc-swagger/build/index.mjs";
import { appRouter, createTRPCContext } from "@homarr/api";
const handler = (req: Request) => {
return createOpenApiFetchHandler({
req,
endpoint: "/",
router: appRouter,
createContext: () => createTRPCContext({ session: null, headers: req.headers }),
});
};
export { handler as GET, handler as POST };

View File

@@ -0,0 +1,8 @@
import { NextResponse } from "next/server";
import { openApiDocument } from "@homarr/api";
import { extractBaseUrlFromHeaders } from "@homarr/common";
export function GET(request: Request) {
return NextResponse.json(openApiDocument(extractBaseUrlFromHeaders(request.headers)));
}