Infrastructure API
All imports on this page use:
ts
import { ... } from '@azure-net/kit/infra';HttpService
TypeScript signature
ts
new HttpService(opts: {
baseUrl: string;
instance?: IHttpServiceInstance;
baseOptions?: Options;
onRequest?: (options: Options) => void | Promise<void>;
onError?: (err: IHttpServiceError) => HttpServiceError<unknown>;
handleError?: (err: unknown) => Promise<HttpServiceError<unknown>>;
})HTTP methods return
ts
get<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>
post<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>
put<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>
patch<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>
delete<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>HttpServiceResponse and HttpServiceError
TypeScript signature
ts
interface IHttpServiceResponse<T> {
headers: Record<string, string>;
status: number;
success: boolean;
data: T;
message: string;
}
interface IHttpServiceError<T> extends IHttpServiceResponse<T> {
original?: Error;
}Both types normalize transport details and are used by parser/error helpers.
QueryBuilder
TypeScript signature
ts
new QueryBuilder(options?: {
objectFormat?: 'default' | 'nested-brackets';
arrayFormat?: 'repeat' | 'brackets' | 'comma' | 'json';
separator?: string;
encode?: boolean;
includeUndefined?: boolean;
})
build(query: Record<string, unknown>, opts?: { includeQuestionMark?: boolean }): string
transform(object: Record<string, unknown>): Record<string, unknown>Serializes query objects into stable URL strings.
ResponseBuilder
Import
ts
import { ResponseBuilder } from '@azure-net/kit/infra';TypeScript signature
ts
class ResponseBuilder<TData, TMeta = unknown, TWrapper = unknown> {
mapUsing<TResource>(ResourceClass: new (data: unknown) => TResource): this;
mapCollectionUsing<TResource>(ResourceClass: new (data: unknown) => TResource): this;
extract<TPath>(path: TPath): this;
addMeta<TNewMeta>(metaData: TNewMeta): ResponseBuilder<TData, TMeta & TNewMeta, TWrapper>;
getData(): TData;
get(): { data: TData; meta: TMeta };
getFlatten(): TData & { meta: TMeta };
getRaw(): TWrapper;
}Pipeline-style mapper for API wrappers and resource shaping.
DTOMapper
Import
ts
import { DTOMapper } from '@azure-net/kit/infra';TypeScript signature
ts
class DTOMapper<TOutput = unknown> {
toPlainObject(): TOutput;
}Base class for DTO/resource object mapping.
BaseHttpDatasource
Import
ts
import { BaseHttpDatasource } from '@azure-net/kit/infra';TypeScript signature
ts
class BaseHttpDatasource<TQueryBuilder = unknown> {
protected createRawRequest<T>(callback: () => Promise<T>): Promise<T>;
}Helper base for datasource classes that wrap raw requests.
HttpStatusCode
Import
ts
import { HttpStatusCode } from '@azure-net/kit/infra';Enum with standard HTTP status constants.