Registry / http-networking / ltrl-http

ltrl-http

JSON →
library0.0.20jsnpmunverified

ltrl-http is a JavaScript/TypeScript library that provides a comprehensive, type-safe collection of HTTP status codes and their corresponding descriptions. It offers both numerical codes and string statuses, along with utility functions for validation and resolution. Currently at version 0.0.20, the package demonstrates a rapid release cadence with frequent patch and minor updates, often related to broader `ltrl` monorepo enhancements, particularly around Nuxt.js integration. Its key differentiators include strong TypeScript typing for HTTP codes and statuses, allowing for compile-time safety, and helper functions like `isHTTPCode` and `useHTTPCode` to work with these values programmatically. It aims to simplify handling HTTP responses by providing a consistent and robust interface for standard HTTP semantics.

npm install ltrl-http
INSTALL
IMPORT
SIG · LTRL-HTTP
L
ltrl-http
http-networkingjavascriptv0.0.20
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

status
import { status } from 'ltrl-http';
const { status } = require('ltrl-http');
The library primarily uses ES module syntax. CommonJS `require` might not work directly without transpilation or specific Node.js configuration.
isHTTPCode
import { isHTTPCode } from 'ltrl-http';
Used for runtime validation of a number against known HTTP status codes.
HTTPCode
import type { HTTPCode } from 'ltrl-http';
This is a TypeScript type union of all available HTTP status code literals, useful for type checking functions that accept HTTP codes.
useHTTPStatus
import { useHTTPStatus } from 'ltrl-http';
Utility function to get an HTTP code from a status string.

Demonstrates importing `status` for direct code access, `isHTTPCode` for validation, and `HTTPCode` for type safety.

import { status, isHTTPCode, HTTPCode } from 'ltrl-http'; // Accessing HTTP status codes directly console.log(`OK: ${status.OK}`); // Output: OK: 200 console.log(`Forbidden: ${status.FORBIDDEN}`); // Output: Forbidden: 403 // Using utility functions const codeToCheck: unknown = 200; if (isHTTPCode(codeToCheck)) { console.log(`${codeToCheck} is a valid HTTP code.`); } else { console.log(`${codeToCheck} is not a valid HTTP code.`); } // Type usage example function handleResponse(code: HTTPCode) { switch (code) { case status.OK: console.log('Request successful!'); break; case status.NOT_FOUND: console.log('Resource not found.'); break; default: console.log(`Unhandled HTTP code: ${code}`); } } handleResponse(status.INTERNAL_SERVER_ERROR); // Expected output: Unhandled HTTP code: 500
Debug
Known issues
breakingThe internal structure of 'congruents' has changed from using 'key' and 'label' fields to a single 'id' field. While `ltrl-http`'s direct exports like `status` are unaffected, custom integrations or direct access to the configuration via `useHTTPCodeConfig()` that rely on the previous field names will break.
fix
Review any code that directly accesses the configuration object returned by `useHTTPCodeConfig()` and update field names from `key` or `label` to `id` as appropriate.
affects: >=0.0.20
gotchaThe `ltrl` project, including `ltrl-http`, is actively developed with frequent minor versions and patches. While this indicates active maintenance, it also means that internal structures and features might evolve rapidly. It's advisable to pin exact versions in production to avoid unexpected behavior changes from sub-minor updates.
fix
Use exact version numbers (e.g., `"ltrl-http": "0.0.20"`) in `package.json` and regularly review changelogs before upgrading.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'OK')
Attempting to access `status.OK` before the module is correctly imported, or if the `status` object is undefined.
fix
Ensure the import statement `import { status } from 'ltrl-http';` is at the top of your file and that your environment supports ES Modules. If using CommonJS, consider transpiling or using dynamic import if available.
TS2307: Cannot find module 'ltrl-http' or its corresponding type declarations.
TypeScript compiler cannot locate the package or its declaration files (`.d.ts`).
fix
Ensure `ltrl-http` is installed (`npm install ltrl-http` or `pnpm add ltrl-http`) and that `moduleResolution` in your `tsconfig.json` is set to a suitable value like `Node16` or `Bundler` for modern module resolution.
Upgrade
Version history
0.0.20latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
ltrl-http — npm install ltrl-http · libregistry