Barakonda
Barakonda2y ago

pipe/unstable_pipe

I cant seem to find it? according to the docs I can chain middlewares using pipe in v10 but the feature isn't there this is a simple example from the docs const t = initTRPC.context<Context>().create(); export const middleware = t.middleware; export const router = t.router; const checkTokenMW = middleware(async ({ctx, next}) => { if(!ctx.req.headers.authorization){ throw new TRPCError({code: 'UNAUTHORIZED'}); } ctx.userData.userId = 3; return next({ctx}); }); const loggerMW = middleware(async ({path, next}) => { const start = Date.now(); const result = await next(); const durationMs = Date.now() - start; result.ok ? console.log('OK request %s duration: %d', { path, durationMs }) : console.log('Non-OK request %s duration: %d', { path, durationMs }); return result; }); I want to do something like this checkTokenMW.unstable_pipe(loggerMW) - or like in the example entering the middleware code directly but there is no method to do this, am i doing something wrong or maybe how to do this changed and the docs aren't updated? can you please help me figure this out?
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Barakonda
Barakonda2y ago
just checked' i have 2 projects in one it exists and in the other it doesn't 10.9.0 - here it doesn't exist but here 10.1.0 it does weird how it exists in an earlier version but was later removed and now returned? or maybe its a bug with typescript?