Ayush GoyalA
tRPC3y ago
3 replies
Ayush Goyal

where does opts.path and opts.type came from ? i guess by default it only stores ctx ,next and input

const loggerMiddleware = middleware(async (opts) => {
  const start = Date.now();
 
  const result = await opts.next();
 
  const durationMs = Date.now() - start;
  const meta = { path: opts.path, type: opts.type, durationMs };
 
  result.ok
    ? console.log('OK request timing:', meta)
    : console.error('Non-OK request timing', meta);
 
  return result;
});
 
export const loggedProcedure = publicProcedure.use(loggerMiddleware);


the code is from middleware documentation
Was this page helpful?