{"id":41267,"library":"http-statuses","title":"http-statuses","description":"Node.js wrapper for HTTP status codes and error creation. Current stable version 0.2.0. Provides an object-oriented interface to access HTTP status codes by name (e.g., BAD_REQUEST, OK), each containing `code`, `message`, and a `createError()` method to generate Node.js Error instances that include the full status data. Lightweight alternative to packages like `http-status` or `http-status-codes`, with built-in error construction support.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/vedi/http-statuses","tags":["javascript","node.js","http","status","response","error","code"],"install":[{"cmd":"npm install http-statuses","lang":"bash","label":"npm"},{"cmd":"yarn add http-statuses","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-statuses","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses CommonJS and does not provide ESM exports. Use require().","wrong":"import HTTP_STATUSES from 'http-statuses';","symbol":"HTTP_STATUSES","correct":"const HTTP_STATUSES = require('http-statuses');"},{"note":"Access statuses by name (e.g., BAD_REQUEST), not by numeric code.","wrong":"HTTP_STATUSES['400']","symbol":"HTTP_STATUSES.BAD_REQUEST","correct":"HTTP_STATUSES.BAD_REQUEST"},{"note":"createError() is a method on the status object, not a constructor.","wrong":"new HTTP_STATUSES.BAD_REQUEST.Error('message')","symbol":"createError","correct":"HTTP_STATUSES.BAD_REQUEST.createError('message')"}],"quickstart":{"code":"const HTTP_STATUSES = require('http-statuses');\nconst express = require('express');\nconst app = express();\napp.get('/', (req, res) => {\n  if (!req.query.ok) {\n    res.status(HTTP_STATUSES.BAD_REQUEST.code)\n       .send(HTTP_STATUSES.BAD_REQUEST.createError('Not ok').message);\n  } else {\n    res.sendStatus(HTTP_STATUSES.OK.code);\n  }\n});\napp.listen(3000, () => console.log('Server on 3000'));","lang":"javascript","description":"Shows how to require the package, access status codes by name, and use createError() in an Express route."},"warnings":[{"fix":"Use require() or dynamic import().","message":"Package does not support ESM imports.","severity":"gotcha","affected_versions":""},{"fix":"Access via HTTP_STATUSES.BAD_REQUEST, not HTTP_STATUSES['400'].","message":"Status objects are not enumerable by numeric code; only by name.","severity":"gotcha","affected_versions":""},{"fix":"Use error.message or error.httpStatus.code; do not rely on instanceof.","message":"createError() returns a plain Error instance, not a custom class. Instanceof checks will fail for custom error classes.","severity":"gotcha","affected_versions":""}],"env_vars":null,"search_vec":"'0.2.0':16 'access':24 'altern':54 'bad':31 'built':68 'built-in':67 'code':9,27,36,65,79 'construct':71 'contain':35 'createerror':40 'creation':12 'current':13 'data':52 'e.g':30 'error':11,45,70,78 'full':50 'generat':43 'http':2,7,25,59,63,75 'http-status':1,58 'http-status-cod':62 'includ':48 'instanc':46 'interfac':22 'javascript':73 'lightweight':53 'like':57 'messag':37 'method':41 'name':29 'node.js':4,44,74 'object':20 'object-ori':19 'ok':33 'orient':21 'packag':56 'provid':17 'request':32 'respons':77 'stabl':14 'status':3,8,26,51,60,64,76 'support':72 'version':15 'wrapper':5","created_at":"2026-06-04T18:51:34.528138+00:00","updated_at":"2026-06-04T18:51:34.528138+00:00","problems":[{"fix":"Run npm install http-statuses","cause":"Package not installed.","error":"Error: Cannot find module 'http-statuses'"},{"fix":"Use const HTTP_STATUSES = require('http-statuses');","cause":"Accessing the module incorrectly (e.g., using default import in ESM).","error":"TypeError: HTTP_STATUSES.BAD_REQUEST.createError is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vedi/http-statuses","github":"https://github.com/vedi/http-statuses","docs":null,"changelog":null,"pypi":null,"npm":"http-statuses","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}