From a939d97babc14c72712b275a76c9fa4b79e65108 Mon Sep 17 00:00:00 2001 From: Qin Guan Date: Sun, 16 Jul 2023 17:23:06 +0800 Subject: [PATCH] chore: debug --- server/trpc/routers/me/index.ts | 4 +++- server/trpc/routers/survey/index.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/trpc/routers/me/index.ts b/server/trpc/routers/me/index.ts index cac9532..4a948e4 100644 --- a/server/trpc/routers/me/index.ts +++ b/server/trpc/routers/me/index.ts @@ -10,8 +10,10 @@ export const meRouter = router({ get: protectedProcedure .meta({ participants: true }) .query(async ({ ctx }) => { - if (await userStorage.hasItem(ctx.session.user.id)) + if (await userStorage.hasItem(ctx.session.user.id)) { + console.log('cached') return await userStorage.getItem(ctx.session.user.id) + } const user = await ctx.prisma.user.findUniqueOrThrow({ where: { id: ctx.session.user.id }, diff --git a/server/trpc/routers/survey/index.ts b/server/trpc/routers/survey/index.ts index 066f211..081d7ef 100644 --- a/server/trpc/routers/survey/index.ts +++ b/server/trpc/routers/survey/index.ts @@ -126,4 +126,16 @@ export const surveyRouter = router({ return survey }), + + delete: protectedProcedure.input( + z.object({ + id: z.string(), + }), + ).mutation(async ({ ctx, input }) => { + await ctx.prisma.survey.delete({ + where: { id: input.id }, + }) + + await surveyStorage.removeItem(input.id) + }), })