NotLuksus
NotLuksus
TtRPC
Created by NotLuksus on 8/19/2024 in #❓-help
Equivalent to middleware on createNextApiHandler
Hey, I'm currently migrating our trpc app to the app router and wondered what the equivalent to the middleware property here would be in app router:
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 handler
export 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,
})
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 handler
export 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,
})
Thank you!
2 replies
TtRPC
Created by NotLuksus on 12/18/2023 in #❓-help
Errors while running mutations when deploying CT3A using SST
No description
5 replies