Registry /
http-networking / express-http-problem-details
Express middleware for RFC 7807 HTTP Problem Details content negotiation. Current stable version 0.2.1. It integrates with http-problem-details-mapper to map custom Node.js errors to standard Problem Documents. Key differentiators: automatic content negotiation based on Accept header, ships TypeScript types, and builds on the PDMLab ecosystem of problem-details libraries. Release cadence is low, with the last release in 2020.
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ESM import; commonjs require works but is discouraged.
import { HttpProblemResponse } from 'express-http-problem-details'
Named export, not default. Available since v0.1.0.
import { ExpressMappingStrategy } from 'express-http-problem-details'
No default export; must destructure in CJS.
const HttpProblemResponse = require('express-http-problem-details').HttpProblemResponse
Express app using HttpProblemResponse middleware to map NotFoundError to RFC 7807 Problem Document.
import express from 'express';
import { HttpProblemResponse } from 'express-http-problem-details';
import { ProblemDocument } from 'http-problem-details';
import { DefaultMappingStrategy, MapperRegistry, ErrorMapper } from 'http-problem-details-mapper';
class NotFoundError extends Error {
constructor({ type, id }) {
super();
this.message = `${type} with id ${id} could not be found.`;
}
}
class NotFoundErrorMapper extends ErrorMapper {
constructor() { super(NotFoundError); }
mapError(error) {
return new ProblemDocument({ status: 404, title: error.message, type: 'http://tempuri.org/NotFoundError' });
}
}
const strategy = new DefaultMappingStrategy(
new MapperRegistry().registerMapper(new NotFoundErrorMapper())
);
const server = express();
server.get('/', (req, res) => { throw new NotFoundError({ type: 'customer', id: '123' }); });
server.use((err, req, res, next) => { console.error(err.stack); next(err); });
server.use(HttpProblemResponse({ strategy }));
server.listen(3000);
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.