UNPKG

@lottojs/ciapa

Version:

Sto bibliotecheto fato in JavaScript, te permete de farghe le chiamate HTTP e ciapar tute le informazioni che te serve par el to progèto.

32 lines (31 loc) 968 B
/// <reference types="node" /> import { z } from 'zod'; export type BasicCredentials = { username: string; password: string; }; export type RequestConfig = { auth?: BasicCredentials; baseUrl?: string; headers?: Record<string, string>; params?: Record<string, string>; withCredentials?: boolean; }; export interface RequestOptions<T> extends RequestInit { responseSchema?: z.ZodSchema<T>; params?: Record<string, string>; } type Method = 'ALL' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD'; export type HttpMethods = { [K in Method]: Lowercase<K>; }[Method]; export type HttpHeader = { name: string; value: string; }; export interface HttpResponse<T> extends Response { data?: T; } export type RequestInterceptor = <T = any>(url: string, request: RequestOptions<T>) => Promise<RequestOptions<T>>; export type ResponseInterceptor = <T = any>(response: HttpResponse<T>) => Promise<HttpResponse<T>>; export {};