api-problem is a JavaScript utility library designed to standardize error responses in HTTP APIs according to RFC 7807, "Problem Details for HTTP APIs." It provides a `Problem` class that allows developers to construct detailed, machine-readable error objects for various HTTP status codes. These objects include a status, human-readable title, a URI identifying the problem type (which defaults to MDN HTTP status pages since v9), and optional additional fields. The current stable version is 9.0.2. The library maintains an active release cadence, primarily focusing on security updates, dependency bumps, CI/CD improvements, and dropping support for older Node.js versions to align with modern JavaScript ecosystems. Its core differentiator is strict adherence to the RFC 7807 specification, ensuring consistent and interoperable error communication across different API clients and servers.
npm install api-problemVerified import paths — ran on the pinned version, not inferred.
Demonstrates the creation of various RFC 7807 problem detail objects with default HTTP meanings, custom titles, types, and additional application-specific details, including how to send a problem as an HTTP response.
Review any code, especially tests or API documentation, that relies on the exact `type` URI for default HTTP problems. Update expectations to account for the new MDN-based URIs, or explicitly set a custom `type` URI during `Problem` instantiation if a specific URI format is required for backward compatibility.
Upgrade your Node.js runtime to version 14 or newer. Consult the official Node.js release schedule for information on currently supported LTS versions.
Ensure your Node.js environment supports ES2015 (Node.js v6+ generally does, but earlier versions might have partial support). It is recommended to use Node.js v14+ in conjunction with this library. No specific changes are needed for typical modern Node.js setups using either ESM `import` or CJS `require`.
Ensure your project is using `api-problem` version 9.0.1 or higher. Regularly update all project dependencies to include security fixes.
For ES Modules, use `import Problem from 'api-problem'`. For CommonJS, use `const Problem = require('api-problem')`. Verify your project's `package.json` `"type"` field and file extensions (.js vs .mjs vs .cjs) to ensure consistent module resolution.Upgrade your Node.js development and deployment environments to version 14 or newer. Consult the official Node.js website for long-term support (LTS) releases and upgrade procedures.
To correctly import the type for the default-exported `Problem` class in TypeScript, use `import type Problem from 'api-problem';`.
No dependency data recorded yet.