import type { MiddlewareHandler } from 'hono';

type Env = {
  Variables: {
    requestId: string;
  };
};

export const requestIdMiddleware: MiddlewareHandler<Env> = async (c, next) => {
  const requestId = crypto.randomUUID();

  c.set('requestId', requestId);
  c.header('X-Request-Id', requestId);

  await next();
};
