Conversation
601d2d1 to
3eb162c
Compare
| const session = await auth(); | ||
| const userId = session?.user?.id; | ||
|
|
||
| await api.leetcode.checkNewCompletions({ |
There was a problem hiding this comment.
could we avoid making the call to the backend if we know that there is no user session?
There was a problem hiding this comment.
changed, please check. is checking "if (session)" enough?
There was a problem hiding this comment.
You can check something like
if (!session?.user) {
return (
<div>
Unauthorized
</div>
)
}But adding
There was a problem hiding this comment.
Would it be better to throw an error (which I think is what happens in weekly-problems?), or should it stay as a simple message?
I was thinking something like
if (!session?.user) {
throw new Error("TRPCError: UNAUTHORIZED");
}but I'd like some feedback before pushing it
There was a problem hiding this comment.
I would say the 'Unauthorized' message is a better choice, as this is not an error but adequate behavior. Perhaps we could add standard 404 or 401 pages later
src/server/api/routers/leetcode.ts
Outdated
| username: input.username, | ||
| }); | ||
| checkNewCompletions: publicProcedure | ||
| .input(z.object({ week: z.number(), userId: z.string(), leetcodeUser: z.string() })) |
There was a problem hiding this comment.
removed the week argument as it was being unused
closes #11