
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-teapot
Advanced tools
Utilities for working with HTTP status codes, errors, and more.
Teapot is an HTTP utility library for JavaScript, which leverages the Node.js HTTP library. It provides the following:
teapot.status(404) and teapot.status('not found') would both
return 404.HTTPError: Base class to represent an HTTP errorClientError and ServerError: Classes to represent 4xx and 5xx errorsNotImplementedError to PaymentRequiredErrorteapot.error(404) would return an
instance of NotFoundError. Great when handling responses from third-party APIs, when you might not know what
status codes to expect all the time.TypeScript definitions are included as well.
With yarn:
$ yarn add node-teapot
With npm:
$ npm install node-teapot
There are a variety of ways to get a status code from a number or string message:
teapot.status.code(404); // 404
teapot.status.code('not implemented'); // 405
teapot.status.codes['BAD GATEWAY']; // 502
teapot.status.MOVED_PERMANENTLY; // 301
teapot.status[200]; // "OK"
Teapot's errors are compatible with Koa and Express:
throw new teapot.InternalServerError('Oops! Something went wrong.');
teapot.error(500) // returns instance of InternalServerError
teapot.error(204) // throws error because 204 is not an error code
teapot.error(404, 'My custom message', { // custom message w/ misc. additional properties
expose: true,
data: {
misc: 'blah',
},
})
See CONTRIBUTING.md for guidelines.
MIT License. See LICENSE file for details.
FAQs
Utilities for working with HTTP status codes, errors, and more
We found that node-teapot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.