@tyforge/http
v0.1.14
Published
Type-safe HTTP client with Result pattern, security hardening, and exception mapping for TyForge
Readme
@tyforge/http
Type-safe HTTP client with Result pattern, security hardening, and exception mapping for TyForge.
Installation
npm install @tyforge/http tyforgeUsage
import { ServiceHttp } from "@tyforge/http";
import { ok } from "tyforge/result";
import { FString, FUrlOrigin, FUrlPath } from "tyforge/type-fields";
class MyApi extends ServiceHttp {
protected readonly _classInfo = { name: "MyApi", version: "1.0.0", description: "API client" };
readonly endpoint = FUrlOrigin.createOrThrow("https://api.example.com");
protected async getAuthHeaders() {
return ok({ "Authorization": FString.createOrThrow("Bearer token") });
}
getUsers() {
return this.get(FUrlPath.createOrThrow("users"));
}
}Security
- SSRF protection (private IP blocking, DNS rebinding detection)
- CRLF injection prevention in headers
- Redirect blocking (
redirect: "error") - Response size limit (10MB)
- Prototype pollution protection in headers
License
MIT
