@lokalise/fastify-extras
Version:
Opinionated set of fastify plugins, commonly used in Lokalise
21 lines (20 loc) • 930 B
TypeScript
import type { ErrorReporter } from '@lokalise/node-core';
import type { FastifyReply, FastifyRequest } from 'fastify';
import type { ZodError } from 'zod/v4';
import type { AnyFastifyInstance } from '../plugins/pluginsCommon.js';
export type FreeformRecord = Record<string, any>;
export type ErrorResponseObject = {
statusCode: number;
payload: {
message: string;
errorCode: string;
details?: FreeformRecord;
};
};
export declare function isZodError(value: unknown): value is ZodError;
export type ErrorHandlerParams = {
errorReporter: ErrorReporter;
resolveResponseObject?: (error: FreeformRecord) => ErrorResponseObject | undefined;
resolveLogObject?: (error: unknown) => FreeformRecord | undefined;
};
export declare function createErrorHandler(params: ErrorHandlerParams): (this: AnyFastifyInstance, error: FreeformRecord, request: FastifyRequest, reply: FastifyReply) => void;