@@ -18,9 +18,9 @@ import { z } from 'zod'
1818import { headers } from ' next/headers'
1919
2020type ORPCContext = { db: ' fake-db' , user? : { id: string } }
21- const base = os .context <ORPCContext >() // define `initial context`
21+ const base = os .$ context <ORPCContext >() // define `initial context`
2222
23- const pub = os .context <ORPCContext >().use (async ({ context , path , next }, input ) => {
23+ const pub = os .$ context <ORPCContext >().use (async ({ context , path , next }, input ) => {
2424 const headersList = await headers ()
2525
2626 // the `user` is `middleware context`, because it is created by middleware
@@ -58,13 +58,13 @@ const base = os.use(async ({ context, path, next }, input) => {
5858})
5959
6060const authMid = os
61- .context <{ db: string }>() // this middleware depends on some context
61+ .$ context <{ db: string }>() // this middleware depends on some context
6262 .middleware (async ({ context , next , path }, input ) => {
6363 const headersList = await headers ()
6464 const user = headersList .get (' Authorization' ) ? { id: ' example' } : undefined
6565
6666 if (! user ) {
67- throw new ORPCError ({ code: ' UNAUTHORIZED' } )
67+ throw new ORPCError (' UNAUTHORIZED' )
6868 }
6969
7070 return next ({
@@ -108,11 +108,11 @@ import { OpenAPIServerlessHandler, OpenAPIServerHandler } from '@orpc/openapi/fe
108108
109109type ORPCContext = { user? : { id: string }, db: ' fake-db' }
110110
111- const base = os .context <ORPCContext >()
111+ const base = os .$ context <ORPCContext >()
112112
113113const authMid = base .middleware (({ context , next , path }, input ) => {
114114 if (! context .user ) {
115- throw new ORPCError ({ code: ' UNAUTHORIZED' } )
115+ throw new ORPCError (' UNAUTHORIZED' )
116116 }
117117
118118 return next ({
0 commit comments