24 lines
704 B
TypeScript
24 lines
704 B
TypeScript
import { appRouter } from '@/helpers/server/routers/appRouterV2'
|
|
import * as Sentry from '@sentry/nextjs'
|
|
import { createOpenApiNextHandler } from 'trpc-openapi'
|
|
import cors from 'nextjs-cors'
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
import { createContext } from '@/helpers/server/context'
|
|
|
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
await cors(req, res)
|
|
|
|
return createOpenApiNextHandler({
|
|
router: appRouter,
|
|
createContext,
|
|
onError({ error }) {
|
|
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
|
Sentry.captureException(error)
|
|
console.error('Something went wrong', error)
|
|
}
|
|
},
|
|
})(req, res)
|
|
}
|
|
|
|
export default handler
|