Skip to content

API Reference

Complete API documentation for all flex-rest exports.

Exports

ts
import BaseApi, { PlaywrightApi, SupertestApi, FlexRestError } from 'flex-rest'
import type { HttpResponse, HttpClient, RequestHook, ResponseHook, BaseApiOptions } from 'flex-rest'

Classes

ClassWrapsDocs
BaseApiAxios / CodeceptJSDefault integration with baseUrl, timeout, retry, hooks, logging
PlaywrightApi@playwright/testFull HTTP method support with safe JSON parsing
SupertestApisupertestIn-process Express/Node.js server testing
FlexRestErrorCustom error thrown on 5xx responses

Interfaces

InterfaceDescription
HttpResponse<T>Unified response shape returned by all methods
HttpClientCommon method contract for all integrations
RequestHook(method, url, headers, payload?) => void
ResponseHook(method, url, response) => void

Common Method Signatures

All classes implement:

ts
get<T>(url: string, headers?: object): Promise<HttpResponse<T>>
post<T>(url: string, payload?: any, headers?: object): Promise<HttpResponse<T>>
put<T>(url: string, payload?: any, headers?: object): Promise<HttpResponse<T>>
patch<T>(url: string, payload?: any, headers?: object): Promise<HttpResponse<T>>
delete<T>(url: string, headers?: object): Promise<HttpResponse<T>>
head<T>(url: string, headers?: object): Promise<HttpResponse<T>>

Released under the MIT License.