Voyageur
Voyageur
TTCTheo's Typesafe Cult
Created by Voyageur on 5/10/2023 in #questions
Next-auth and standalone trpc
My team is using nextjs with a standalone trpc server and I'm trying to set up Next-Auth. When I try to run getServerSession on the request in order to add it to my trpc context I'm just receiving null, and I also have a type error coming up:
Argument of type '[IncomingMessage, ServerResponse<IncomingMessage>, AuthOptions]' is not assignable to parameter of type 'GetServerSessionParams<AuthOptions>'.
Type '[IncomingMessage, ServerResponse<IncomingMessage>, AuthOptions]' is not assignable to type '[IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }, ServerResponse<IncomingMessage>, AuthOptions]'.
Type at position 0 in source is not compatible with type at position 0 in target.
Type 'IncomingMessage' is not assignable to type 'IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }'.
Property 'cookies' is missing in type 'IncomingMessage' but required in type '{ cookies: Partial<{ [key: string]: string; }>; }'.ts(2345)
Argument of type '[IncomingMessage, ServerResponse<IncomingMessage>, AuthOptions]' is not assignable to parameter of type 'GetServerSessionParams<AuthOptions>'.
Type '[IncomingMessage, ServerResponse<IncomingMessage>, AuthOptions]' is not assignable to type '[IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }, ServerResponse<IncomingMessage>, AuthOptions]'.
Type at position 0 in source is not compatible with type at position 0 in target.
Type 'IncomingMessage' is not assignable to type 'IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }'.
Property 'cookies' is missing in type 'IncomingMessage' but required in type '{ cookies: Partial<{ [key: string]: string; }>; }'.ts(2345)
Is it even possible to run next-auth in the standalone server or do I need at least express to parse the request properly? I tried parsing out the cookie and then passing a restructured request into the getServerSession function, but that didn't work.
2 replies
TTCTheo's Typesafe Cult
Created by Voyageur on 4/25/2023 in #questions
Type safety in apollo server
Big fan of t3/trpc but work uses apollo server. Is there any way to incorporate end to end type safety in apollo server?
2 replies