| 1 | import { OpenAPIHandler } from "@orpc/openapi/fetch"; |
| 2 | import { OpenAPIReferencePlugin } |
| 3 | import { onError } |
| 4 | import { RPCHandler } |
| 5 | import { ZodToJsonSchemaConverter } |
| 6 | import { createContext } |
| 7 | import { appRouter } |
| 8 | import { NextRequest } |
| 9 | import { revalidateTag } |
| 10 | import { INSTANCE_SETTINGS_TAG } |
| 11 | |
| 12 | import { withEvlog } |
| 13 | import { identifyEvlogUser } |
| 14 | |
| 15 | const rpcHandler = new |
| 16 | interceptors: [ |
| 17 | onError((error) |
| 18 | console.error(error |
| 19 | }), |
| 20 | ], |
| 21 | }); |
| 22 | const apiHandler = new |
| 23 | plugins: [ |
| 24 | new OpenAPIReferencePlugin({ |
| 25 | schemaConverters: [new ZodToJsonSchemaConverter |
| 26 | }), |
| 27 | ], |
| 28 | interceptors: [ |
| 29 | onError((error) |
| 30 | console.error(error |
| 31 | }), |
| 32 | ], |
| 33 | }); |
| 34 | |
| 35 | async function handleRequest( |
| 36 | await identifyEvlogUser(req |
| 37 | const ctx = |
| 38 | ctx.revalidate = |
| 39 | const rpcResult = |
| 40 | prefix: "/api/rpc", |
| 41 | context: ctx, |
| 42 | }); |
| 43 | if (rpcResult.response |
| 44 | |
| 45 | const apiResult = |
| 46 | prefix: "/api/rpc/api-reference", |
| 47 | context: ctx, |
| 48 | }); |
| 49 | if (apiResult.response |
| 50 | |
| 51 | return new Response |
| 52 | } |
| 53 | |
| 54 | export const GET = |
| 55 | export const POST = |
| 56 | export const PUT = |
| 57 | export const PATCH = |
| 58 | export const DELETE = |