⬆️ v3.0.0 (#704)

This commit is contained in:
Luke Vella 2023-06-19 17:17:00 +01:00 committed by GitHub
parent 735056f25f
commit c22b3abc4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
385 changed files with 19912 additions and 5250 deletions

View file

@ -4,16 +4,20 @@ import z from "zod";
import { decryptToken } from "../../session";
import { publicProcedure, router } from "../trpc";
import { LoginTokenPayload, UserSession } from "../types";
import { LoginTokenPayload } from "../types";
export const whoami = router({
get: publicProcedure.query(async ({ ctx }): Promise<UserSession> => {
get: publicProcedure.query(async ({ ctx }) => {
if (ctx.user.isGuest) {
return { isGuest: true, id: ctx.user.id };
return { isGuest: true as const, id: ctx.user.id };
}
const user = await prisma.user.findUnique({
select: { id: true, name: true, email: true },
select: {
id: true,
name: true,
email: true,
},
where: { id: ctx.user.id },
});
@ -22,7 +26,7 @@ export const whoami = router({
throw new Error("User not found");
}
return { isGuest: false, ...user };
return { isGuest: false as const, ...user };
}),
destroy: publicProcedure.mutation(async ({ ctx }) => {
ctx.session.destroy();