@@ -14,7 +14,7 @@ export class Context<TContext extends Record<string, unknown> = Record<string, u
1414 this . db = ctx . db as any
1515 }
1616
17- get < TName extends keyof TContext > ( name : TName ) : TContext [ TName ] {
17+ get < TName extends Exclude < keyof TContext , 'db' > > ( name : TName ) : TContext [ TName ] {
1818 const value = this . ctx [ name ]
1919 if ( value === undefined ) {
2020 throw new Error ( `Key "${ String ( name ) } " not found in context.` )
@@ -28,12 +28,6 @@ export class Context<TContext extends Record<string, unknown> = Record<string, u
2828 ) : RequestContext < TContext > {
2929 return new RequestContext < TContext > ( ctx . ctx , ctx . authContext , headers )
3030 }
31-
32- static getCtx < TContext extends Record < string , unknown > = Record < string , unknown > > (
33- ctx : Context < TContext >
34- ) : TContext {
35- return ctx . ctx
36- }
3731}
3832
3933export class RequestContext <
@@ -67,19 +61,18 @@ export class RequestContext<
6761 return this . _headers
6862 }
6963
70- override get <
71- TKey extends string | number | symbol ,
72- TValue extends TKey extends keyof TContext ? TContext [ TKey ] : any ,
73- > ( name : TKey ) : TValue {
64+ override get < TKey extends Exclude < keyof TContext , 'db' > > ( name : TKey ) : TContext [ TKey ]
65+ override get ( name : string ) : unknown
66+ override get ( name : string ) : unknown {
7467 try {
75- const value = this . ctx [ name as keyof TContext ]
76- return value as TValue
68+ const value = super . get ( name as any )
69+ return value
7770 } catch {
7871 const value = this . _state [ name as string ]
7972 if ( value === undefined ) {
8073 throw new Error ( `Key "${ String ( name ) } " not found in context.` )
8174 }
82- return value as TValue
75+ return value
8376 }
8477 }
8578
0 commit comments