// Minimal permissive Express-ish request/response types for the migrated routes
// and middleware. @types/express is not installed and the handlers are dynamic
// (req.user is added by requireAuth, req.body/query are user input), so these
// carry an index signature — typed enough for `.json()/.status()` chaining and
// the common fields, permissive everywhere else. Swap for @types/express +
// declaration-merged `user` if the routes ever warrant full typing.

export interface Req {
  body: any;
  params: any;
  query: any;
  user?: any;
  ip?: string;
  method: string;
  path?: string;
  originalUrl?: string;
  headers: any;
  cookies?: any;
  signedCookies?: any;
  secure?: boolean;
  csrfSkip?: boolean;
  file?: any;
  files?: any;
  get(name: string): string | undefined;
  header(name: string): string | undefined;
  [k: string]: any;
}

export interface Res {
  json(body?: any): Res;
  status(code: number): Res;
  send(body?: any): Res;
  end(body?: any): Res;
  cookie(name: string, value: any, options?: any): Res;
  clearCookie(name: string, options?: any): Res;
  setHeader(name: string, value: any): void;
  getHeader(name: string): any;
  set(field: string, value?: any): Res;
  type(t: string): Res;
  redirect(url: string): void;
  download(path: string, filename?: string, cb?: (err?: any) => void): void;
  sendFile(path: string, options?: any, cb?: (err?: any) => void): void;
  attachment(filename?: string): Res;
  locals: any;
  headersSent: boolean;
  [k: string]: any;
}

export type Next = (err?: any) => void;

// An Express router (the shape `express.Router()` returns) — permissive.
export interface Router {
  get(path: string, ...handlers: any[]): void;
  post(path: string, ...handlers: any[]): void;
  put(path: string, ...handlers: any[]): void;
  patch(path: string, ...handlers: any[]): void;
  delete(path: string, ...handlers: any[]): void;
  use(...handlers: any[]): void;
  [k: string]: any;
}
