const isAuthed = t.middleware(async ({ ctx, next }) => { initApi(); const cookies = ctx.cookies; const headers = ctx.headers; const auth = admin.auth(); if(headers && headers.token && typeof headers.token === 'string') { const {uid} = await auth.verifyIdToken(headers.token); } else { throw new TRPCError({ code: 'UNAUTHORIZED', }) } return next({ ctx: { isAuthed: cookies && cookies.authed, }, });});