-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Make router operations injectable #288
Conversation
tannerlinsley
commented
Jul 17, 2024
- Makes router operations injectable
- Makes router context generic
- Still adheres to Remix's sessionStorage and session API's
@@ -74,6 +75,8 @@ | |||
"typescript": "^5.1.6" | |||
}, | |||
"dependencies": { | |||
"@tanstack/react-router": "^1.45.4", | |||
"@tanstack/start": "^1.45.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't end up here. It would likely end up in a tanstack-auth
package along with the TanStackAuthenticator
class.
sessionKey?: AuthenticateOptions<TContext>["sessionKey"]; | ||
sessionErrorKey?: AuthenticateOptions<TContext>["sessionErrorKey"]; | ||
sessionStrategyKey?: AuthenticateOptions<TContext>["sessionStrategyKey"]; | ||
throwOnError?: AuthenticateOptions<TContext>["throwOnError"]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the sessionStorage to the options to bring things down to a single required options bag. This is breaking (but then again, much of this is), but has proven to be a good change in our TanStack libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a non-breaking change if the current API is still implemented by the RemixAuthenticator
redirect, | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also imagine that this would need to stay in the "remix-auth" package while most everything else would need to go into some core package.
Session, | ||
SessionStorage, | ||
} from "@remix-run/server-runtime"; | ||
import { isSession, Session, SessionStorage } from "@remix-run/server-runtime"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still using a Remix package, would it be ok for TSS to depend on this? This doesn't really depend on anything from Remix, maybe it could convince the team to move them to a separate agnostic package?
Another option could be to make Authenticator use another interface like's unstorage and provider wrappers of SessionStorage for unstorage in the Remix package and another in the TanStack package.
export interface AuthenticatorImplOptions { | ||
redirect: ( | ||
url: string, | ||
options?: { headers?: HeadersInit } | ||
) => Response | Promise<Response>; | ||
json: <T>(data: T, status?: number) => Response; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to provide this from TanStack? At least in Remix they only wrap new Response()
, in that case they could be implemented right here
I published Remix Auth v4 where now it doesn't depend at all on Remix or RRv4, just on being able to pass a Request object. |
Woo! 🎉 |