Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / http

http

The @zerotal/core/http module — everything for talking HTTP from the server side and shaping HTTP responses. It groups five concerns:

  • Outbound requests — the Http facade and its fluent PendingRequest builder for server-to-server calls, with headers, auth, timeouts, retries, and a fake() test harness.
  • URL building & signing — the immutable Uri value object (uri) and the app-aware Url service (url) for fully-qualified, named-route, and HMAC-signed links.
  • UploadsUploadedFile for validating and storing multipart form files.
  • API resourcesResource and ResourceCollection for transforming models into JSON response envelopes.
  • Content negotiationnegotiate / detectChannel for branching a handler by web / JSON / CLI client.

Example

import { Http, uri } from '@zerotal/core/http';

const target = uri('https://api.example.com/users').withQuery({ page: 2 }).value();
const users  = await Http.withToken(token).timeout(5000).get(target).json();

@packageDocumentation

Classes

Interfaces

Type Aliases

Variables

Functions