import { Request, Response, NextFunction } from 'express'; /** * Express middleware that maps repository errors to appropriate HTTP responses. * Automatically handles ValidationError (400), InvalidDocumentIdError (400), * InvalidPaginationCursorError (400), NotFoundError (404), FirestoreIndexError (503), * ConflictError (409), PreconditionFailedError (412), WriteOutcomeError (500 with safe outcome * metadata), and generic errors (500). * * Imported from the optional `flintfire/express` subpath so `express` stays out * of the core package's type graph. `express` is declared as an optional peer dependency — install * it only if you use this adapter. * * @param err - Error object thrown by repository or application code * @param req - Express request object * @param res - Express response object * @param next - Express next function * * @example * // Register as global error handler in Express * import { errorHandler } from 'flintfire/express'; * * app.use(errorHandler); * * @example * // Use in route handlers * app.post('/users', async (req, res, next) => { * try { * const user = await userRepo.create(req.body); * res.json(user); * } catch (error) { * next(error); // errorHandler will process this * } * }); * * @example * // Response for ValidationError (400) * { * "error": "ValidationError", * "details": [ * { "path": ["email"], "message": "Invalid email" }, * { "path": ["age"], "message": "Must be positive" } * ] * } * * @example * // Response for NotFoundError (404) * { * "error": "NotFoundError", * "message": "Document with id user-123 not found" * } * * @example * // Response for ConflictError (409) * { * "error": "ConflictError", * "message": "Email already exists" * } * * @example * // Response for PreconditionFailedError (412) * // Message text is whatever the thrown error carried — do not match on server wording (emulator * // Datastore-flavored strings differ from production). * { * "error": "PreconditionFailedError", * "message": "Write precondition failed" * } */ export declare function errorHandler(err: any, req: Request, res: Response, _next: NextFunction): Response>;