Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Jul 16, 2023
1 parent 072d0bf commit 5b12b0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/trpc/routers/survey/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export const surveyRouter = router({
).query(async ({ ctx, input }) => {
if (await surveyStorage.hasItem(input.id)) {
const survey = await surveyStorage.getItem<Survey>(input.id)
if (!survey) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
})
}

return {
...survey,
Expand Down Expand Up @@ -58,7 +63,7 @@ export const surveyRouter = router({

list: protectedProcedure.query(async ({ ctx }) => {
if (await surveyStorage.hasItem('__all_surveys'))
return await surveyStorage.getItem<Survey[]>('__all_surveys')
return await surveyStorage.getItem<Survey[]>('__all_surveys') ?? []

const surveys = await ctx.prisma.survey.findMany()
await surveyStorage.setItem('__all_surveys', surveys)
Expand Down

0 comments on commit 5b12b0d

Please sign in to comment.