From 5b12b0d9955e8f2a8077e21b406d9123e3f6c250 Mon Sep 17 00:00:00 2001 From: Qin Guan Date: Sun, 16 Jul 2023 16:40:02 +0800 Subject: [PATCH] fix: types --- server/trpc/routers/survey/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/trpc/routers/survey/index.ts b/server/trpc/routers/survey/index.ts index c0ffcd2..066f211 100644 --- a/server/trpc/routers/survey/index.ts +++ b/server/trpc/routers/survey/index.ts @@ -18,6 +18,11 @@ export const surveyRouter = router({ ).query(async ({ ctx, input }) => { if (await surveyStorage.hasItem(input.id)) { const survey = await surveyStorage.getItem(input.id) + if (!survey) { + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + }) + } return { ...survey, @@ -58,7 +63,7 @@ export const surveyRouter = router({ list: protectedProcedure.query(async ({ ctx }) => { if (await surveyStorage.hasItem('__all_surveys')) - return await surveyStorage.getItem('__all_surveys') + return await surveyStorage.getItem('__all_surveys') ?? [] const surveys = await ctx.prisma.survey.findMany() await surveyStorage.setItem('__all_surveys', surveys)