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) + }), })