Registry / http-networking / know-your-http-well

know-your-http-well

JSON →
library0.5.0jsnpmunverified

know-your-http-well is a JavaScript package that provides structured data for various HTTP specifications, including headers, media types, methods, relations, and status codes. It summarizes these elements and links directly to their respective RFCs and specifications. The current stable version is v0.6.0, with minor content updates driving recent releases. Its primary use case is to offer programmatic access to standardized HTTP information, such as converting status phrases to codes and vice-versa, making it useful for both server-side and client-side applications that need to interpret or generate HTTP messages correctly. The project serves as a reference data set, updated periodically with new RFCs and corrections, rather than offering complex runtime functionality or a rapid release cadence for API changes. Its key differentiator is providing this data in an easily consumable JSON and JavaScript format, directly referencing official specifications.

npm install know-your-http-well
INSTALL
IMPORT
SIG · KNOW-YOUR-HTTP-WEL
K
know-your-http-well
http-networkingjavascriptv0.5.0
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.

httpWell
const httpWell = require('know-your-http-well');
import httpWell from 'know-your-http-well';
This package is a CommonJS module. For ESM, use 'import * as httpWell from "know-your-http-well";' and access properties like 'httpWell.statusPhrasesToCodes'.
statusPhrasesToCodes
const { statusPhrasesToCodes } = require('know-your-http-well');
import { statusPhrasesToCodes } from 'know-your-http-well';
Named imports from this CommonJS module directly are not supported without explicit interop configuration (e.g., in a bundler or 'type: module' with Node.js loaders).
statusCodesToPhrases
const { statusCodesToPhrases } = require('know-your-http-well');
import { statusCodesToPhrases } from 'know-your-http-well';
As a CommonJS module, direct named imports (`import { ... } from 'pkg'`) are typically not functional. Use object destructuring with `require` or an aliased star import for ESM.

Demonstrates importing the package using CommonJS and accessing HTTP status code utilities for both numerical codes and their corresponding phrases.

const httpWell = require('know-your-http-well'); const statusWell = httpWell.statusPhrasesToCodes; const phraseWell = httpWell.statusCodesToPhrases; // Example: Server-side usage // In a hypothetical Express-like response handler: // res.statusCode = statusWell.NOT_FOUND; // console.log(`Set status to ${statusWell.NOT_FOUND}`); // Example: Client-side or common logic const responseStatusCode = 404; // Simulate a response status if (responseStatusCode !== statusWell.OK) { // Log 'Request returned 404 Not Found' console.log('Request returned ' + responseStatusCode + ' ' + phraseWell[responseStatusCode]); } // Expected output: Request returned 404 Not Found
Debug
Known issues
gotchaThis package is distributed as a CommonJS module. When using it in an ECMAScript Module (ESM) environment (e.g., Node.js with 'type: module' or modern frontend builds), standard named imports (`import { Name } from 'pkg'`) will not work directly. You must use `import * as pkg from 'pkg';` or rely on bundler/runtime interop.
fix
For ESM, use `import * as httpWell from 'know-your-http-well';` and access properties as `httpWell.statusPhrasesToCodes`. Alternatively, ensure your build setup correctly handles CommonJS interoperability.
affects: >=0.1.0
gotchaThe package primarily provides data via JavaScript objects. While the data is derived from RFCs, its structure (e.g., property names for status codes like `NOT_FOUND`) might evolve slightly between minor versions to reflect new specifications or corrections. Always test after updates.
fix
Consult the changelog for each new version to understand any structural changes to the exported data objects, especially if you rely on specific keys or formats.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require()` in an ECMAScript Module (ESM) context without proper configuration or a `createRequire` helper.
fix
For ESM, change `const httpWell = require('know-your-http-well');` to `import * as httpWell from 'know-your-http-well';`. If you need CommonJS specifically in an ESM file, use `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`.
TypeError: Cannot read properties of undefined (reading 'NOT_FOUND')
This usually occurs if the `know-your-http-well` package was not correctly imported, or the `statusPhrasesToCodes` (aliased as `statusWell` in the quickstart) object itself is undefined or lacks the 'NOT_FOUND' property. This can happen with incorrect ESM imports.
fix
Ensure you are importing the package correctly, especially in ESM environments. Use `import * as httpWell from 'know-your-http-well';` then access `httpWell.statusPhrasesToCodes.NOT_FOUND`. Verify the exact case ('NOT_FOUND' vs 'NotFound') for status codes.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
know-your-http-well — npm install know-your-http-well · libregistry