/**
 * Terminal middleware for unmatched routes. Hands an AppError to the error
 * handler so a 404 comes out in the same JSON shape as every other error — never
 * Express's default HTML page (which the frontend would hit as an HTML-parse
 * crash rather than a caught ApiError; PLANNING.md §5).
 */
import type { NextFunction, Request, Response } from 'express';
import { AppError } from '../lib/AppError';

export function notFound(req: Request, _res: Response, next: NextFunction): void {
  next(AppError.notFound(`Cannot ${req.method} ${req.path}`));
}
