aselcuktuncer
Why deprecate experimental_standaloneMiddleware?
because 'Creating middlewares using t.middleware has the limitation that the Context type is tied to the Context type of the tRPC instance'. i want to create a standalone middleware like this:
const projectAccessMiddleware = experimental_standaloneMiddleware<{
ctx: { allowedProjects: string[] }; // defaults to 'object' if not defined
input: { projectId: string }; // defaults to 'unknown' if not defined
// 'meta', not defined here, defaults to 'object | undefined'
}>().create((opts) => {
and then i just want to use it in the router like this:
.use(projectAccessMiddleware);
using concat() and creating a plugin result in creating a new procedure as far as i understand but i do not want to create a new procedure i just want to use a middleware. as like in the example code input and ctx objects may include different values like userId, projectId etc which comes from input(). it was really easy to create new standalone middlewares earlier and now we have have to create a new produceure or *concat() * plugins to existing procedures to later use in the router? i mean now it looks like standalone middlewares are tied to procedures directly and this is not the exact alternative for experimental_standaloneMiddleware right?5 replies