{"id":18333,"library":"express-http-problem-details","title":"Express HTTP Problem Details","description":"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.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/PDMLab/express-http-problem-details","tags":["javascript","express","error","http","problem","rfc7807","conneg","typescript"],"install":[{"cmd":"npm install express-http-problem-details","lang":"bash","label":"npm"},{"cmd":"yarn add express-http-problem-details","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-http-problem-details","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for middleware integration","package":"express","optional":false}],"imports":[{"note":"ESM import; commonjs require works but is discouraged.","wrong":"const { HttpProblemResponse } = require('express-http-problem-details')","symbol":"HttpProblemResponse","correct":"import { HttpProblemResponse } from 'express-http-problem-details'"},{"note":"Named export, not default. Available since v0.1.0.","wrong":"import ExpressMappingStrategy from 'express-http-problem-details'","symbol":"ExpressMappingStrategy","correct":"import { ExpressMappingStrategy } from 'express-http-problem-details'"},{"note":"No default export; must destructure in CJS.","wrong":"const HttpProblemResponse = require('express-http-problem-details')","symbol":"default","correct":"const HttpProblemResponse = require('express-http-problem-details').HttpProblemResponse"}],"quickstart":{"code":"import express from 'express';\nimport { HttpProblemResponse } from 'express-http-problem-details';\nimport { ProblemDocument } from 'http-problem-details';\nimport { DefaultMappingStrategy, MapperRegistry, ErrorMapper } from 'http-problem-details-mapper';\n\nclass NotFoundError extends Error {\n  constructor({ type, id }) {\n    super();\n    this.message = `${type} with id ${id} could not be found.`;\n  }\n}\n\nclass NotFoundErrorMapper extends ErrorMapper {\n  constructor() { super(NotFoundError); }\n  mapError(error) {\n    return new ProblemDocument({ status: 404, title: error.message, type: 'http://tempuri.org/NotFoundError' });\n  }\n}\n\nconst strategy = new DefaultMappingStrategy(\n  new MapperRegistry().registerMapper(new NotFoundErrorMapper())\n);\n\nconst server = express();\nserver.get('/', (req, res) => { throw new NotFoundError({ type: 'customer', id: '123' }); });\nserver.use((err, req, res, next) => { console.error(err.stack); next(err); });\nserver.use(HttpProblemResponse({ strategy }));\nserver.listen(3000);","lang":"typescript","description":"Express app using HttpProblemResponse middleware to map NotFoundError to RFC 7807 Problem Document."},"warnings":[{"fix":"Ensure HttpProblemResponse is the last error-handling middleware.","message":"Middleware must be placed after all other error-handling middleware that sends responses, otherwise Problem Document may not be generated.","severity":"gotcha","affected_versions":"*"},{"fix":"Use DefaultMappingStrategy from http-problem-details-mapper instead.","message":"ExpressMappingStrategy was deprecated in v0.2.0 in favor of DefaultMappingStrategy from http-problem-details-mapper.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Install express separately: npm install express.","message":"The package does not include express as a dependency; it must be installed separately.","severity":"gotcha","affected_versions":"*"},{"fix":"Always pass an object with a 'strategy' property that implements MappingStrategy.","message":"HttpProblemResponse expects a 'strategy' option; omitting it will cause a runtime error.","severity":"gotcha","affected_versions":"*"},{"fix":"Import { HttpProblemResponse } from 'express-http-problem-details' (capital H).","message":"In v0.1.0, the middleware was named 'httpProblemResponse' (lowercase); renamed to 'HttpProblemResponse' in v0.2.0.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'0.2.1':18 '2020':68 '7807':9 'accept':43 'automat':38 'base':41 'build':49 'cadenc':60 'conneg':75 'content':13,39 'current':15 'custom':29 'detail':4,12,25,57 'differenti':37 'document':35 'ecosystem':53 'error':31,71 'express':1,5,70 'header':44 'http':2,10,23,72 'http-problem-details-mapp':22 'integr':20 'javascript':69 'key':36 'last':65 'librari':58 'low':62 'map':28 'mapper':26 'middlewar':6 'negoti':14,40 'node.js':30 'pdmlab':52 'problem':3,11,24,34,56,73 'problem-detail':55 'releas':59,66 'rfc':8 'rfc7807':74 'ship':45 'stabl':16 'standard':33 'type':47 'typescript':46,76 'version':17","created_at":"2026-04-25T07:37:42.086823+00:00","updated_at":"2026-04-25T07:37:42.086823+00:00","problems":[{"fix":"server.use(HttpProblemResponse({ strategy }))","cause":"HttpProblemResponse called without arguments.","error":"TypeError: Cannot destructure property 'strategy' of 'undefined' or 'null'"},{"fix":"Use an instance of DefaultMappingStrategy from http-problem-details-mapper.","cause":"The 'strategy' object does not implement the MappingStrategy interface.","error":"TypeError: strategy.mapError is not a function"},{"fix":"Call registerMapper multiple times, or pass mappers individually.","cause":"MapperRegistry.registerMapper() expects a single mapper, not an array.","error":"TypeError: (intermediate value) is not iterable"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/PDMLab/express-http-problem-details","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/express-http-problem-details","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}