@phonecheck/phone-number-validator-js
Version:
Validate, parse, and enrich international phone numbers — geocoding, carrier lookup, and timezone resolution. Sync (Node) + async (serverless) APIs, platform adapters, and a CLI.
51 lines (50 loc) • 1.85 kB
TypeScript
import { type LambdaResult } from '../_shared/lambda-helpers';
import { type ValidationRequestBody } from '../_shared/validation';
export interface APIGatewayProxyEvent {
body: string | null;
headers: {
[key: string]: string | undefined;
};
httpMethod: string;
path: string;
queryStringParameters: {
[key: string]: string | undefined;
} | null;
pathParameters: {
[key: string]: string | undefined;
} | null;
isBase64Encoded?: boolean;
}
export type APIGatewayProxyResult = LambdaResult;
export interface LambdaContext {
functionName: string;
functionVersion: string;
awsRequestId: string;
remainingTimeInMillis: number;
}
interface ValidateResponse {
success: boolean;
data?: unknown;
error?: string;
}
/** Classic API-Gateway shape — no path routing; body classifies single vs batch. */
export declare function apiGatewayHandler(event: APIGatewayProxyEvent, _context?: LambdaContext): Promise<APIGatewayProxyResult>;
/** Direct invocation — no API Gateway envelope. */
export declare function lambdaHandler(event: ValidationRequestBody, _context?: LambdaContext): Promise<ValidateResponse>;
/** Cache management — invoke directly with `{ action: 'clear' | 'stats' }`. */
export declare function cacheHandler(event: {
action: 'clear' | 'stats';
}, _context?: LambdaContext): Promise<{
success: boolean;
message?: string;
stats?: unknown;
}>;
/** Routed handler — `/health`, `/validate`, `/validate/batch`. */
export declare function handler(event: APIGatewayProxyEvent, _context?: unknown): Promise<APIGatewayProxyResult>;
declare const _default: {
apiGatewayHandler: typeof apiGatewayHandler;
lambdaHandler: typeof lambdaHandler;
cacheHandler: typeof cacheHandler;
handler: typeof handler;
};
export default _default;