import { createNextApiHandler } from '@trpc/server/adapters/next'import { env } from '~/env.mjs'import { appRouter } from '~/server/api/routers/app.router'import { createTRPCContext } from '~/server/api/trpc'import { initBudgetAsyncLocalStorage } from '~/server/lib/getBudgetCached'// export API handlerexport default createNextApiHandler({ router: appRouter, createContext: createTRPCContext, middleware: (_res, _req, next) => { initBudgetAsyncLocalStorage() return next() }, onError: env.NODE_ENV === 'development' ? ({ path, error }) => { console.error( `❌ tRPC failed on ${path ?? '<no-path>'}: ${error.message}` ) } : undefined,})