TRPC Middleware w/ Input

LLermatroid5/4/2023
Hello!

I was wondering if there is a way to add input fields onto a TRPC middleware. Essentially I would like a token field to be required on any inputs through the procedure that uses this middleware. How would I go about this?

Thanks!
LLermatroid5/4/2023
I have this right now, but would like it if instead of headers in was added in the input of the query or mutation.

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,
        },
    });
});
Nnlucas5/4/2023
We have a ticket open for this already
Nnlucas5/4/2023
If you write an in-line middleware directly on a procedure then you can access the input in a type safe way already