-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Various ideas to discuss #306
Comments
+1, Agree with all, but I've the same opinion for point 3, not feeling that it should come on the cli |
1 and 2 looks fine. Haven't used 1 myself but seems reasonable if it's a 1-liner. Not a fan of 3 tbh. Implementing the installer would be a pain if we should support selecting both since basically every file will conflict and we would need duplicates for all of them. 4 seems like a user-issue and will soon be irrelevant since Next is changing their router and layout, not sure how far away that is but it is in the works 5a (req/res) looks good, definitely should get rid of passing req/res around. 5b (session cb) Not sure if there is any performance gains in sending a callback function instead of the session? Is it really that heavy? |
I was thinking about having the option to select one or another (not both). But, I understand that it may be somewhat painful to implement.
I wouldn't consider it a user-issue, because it removes some boilerplate that the dev must write just to have per-page layouts.
To prove that it can hit performances, suppose you have a procedure that simply fetches some public posts that everyone (even non-logged in users) can see. The db queries would look something like:
Why would I need to get the user session if I just want to retrieve some public posts?
But still have the possibility to have auth-protected procedures (through the session cb inside
|
That's not correct though (right?? please correct me if I'm wrong). export const userRouter = t.router({
me: authedProcedure.query(async ({ ctx }) => {
// from cookie
const user = ctx.session.user;
// from db
const dbUser = await ctx.prisma.user.findFirst({
where: {
id: user.id,
},
});
return dbUser;
}),
}); so I don't think the gains are any significant |
You are absolutely right. return await ctx.prisma.post.findMany({
where: { authorId: ctx.session?.user?.id },
}) causes these queries: Back to the other points, should I open a PR for 1 and 2? And is your opinion still the same for points 3 and 4 @juliusmarminge? |
Yes! Please file a PR for 1 and 2. I vote no for 3 and 4 but there may be others who thinks otherwise. |
Unsure what you mean by this. The return-statement you are referring to should be a single SQL query with joins if I'm not mistaken. |
I agree about no for 3 and 4, because adding those things is no different than it would be in any other project/template. |
Same |
This change should not be made. The |
Nice catch. Wanna make a PR reverting the change? |
I came here trying to solve typing burden with getLayout approach. Not voting for having it in by default but it would be much appreciated if anyone can share a snippet. I have failed to combine typings of api.withTRPC, next-auth session and custom geLayout property on Component.
Documentation strongly avoids from moving in that direction since |
If you are willing to typecast the getLayout function you can do the following:
This avoids most of the typing problems and is close to the implementation of the next docs (except NextPageWithLayout now returns a React.ReactElement). |
I've opened #1363 to discuss point 4. |
Is your feature request related to a problem? Please describe.
First of all, I'd like to say that I really like this project and appreciate all the work that has been done by the community.
I'm opening this issue to discuss some features that I think could be added (I don't want to spam the issues section).
Starting from the minor adjustments
teardown
, this can be easily done by adding one line:Major features
Do you guys think that having a jwt-based strategy as a option could benefit the project? For example, a possible cli step:
context.ts
can be improved, because currently thereq
/res
object are being passed around for all procedures. PR chore: fix context #186 already fixes this issue but can be improved even further (after the merge maybe). The main problem is in the fact thatcreateContext
is called for each request, sogetServerSession
is called everytime we call the API and even endpoints that don't need to be authenticated will have to wait for the fetching of the user session: this can be solved by passing a function down to all procedures, as such:Final considerations
I know I have shown a lot of stuff in this single issue (maybe a discussion section would be more approriate!),
but feel free to discuss (and reject) all the points: in particular, point 3 may need a lot of code to be implemented.
If help is needed, I can happily contribute to the project and open PRs.
The text was updated successfully, but these errors were encountered: