npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

response-status-code

v1.0.5

Published

[![npm version](https://badge.fury.io/js/response-status-code.svg)](https://www.npmjs.com/package/response-status-code)

Downloads

11

Readme

HTTP Status Codes for Express

npm version

This npm package provides a convenient way to use HTTP status codes with Express.js applications. It exports an object containing all standard HTTP status codes, making it easy to reference them in your Express routes.

Installation

You can install the package via npm:

bash

npm install response-status-code

Usage

Importing You can import the HTTP status codes object as http:

const http = require("response-status-code");

Or if you're using ES6 modules:

import http from "response-status-code";

Example

Here's how you can use it in an Express route:

const express = require("express");
const app = express();
const http = require("response-status-code");

app.get("/example", (req, res) => {
  // Send a 200 OK response
  res.status(http.statusOk).send("This is an example route");
});

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

Available Status Codes

The package exports all standard HTTP status codes as properties of the http object. For example:

| Status Code | Description | Function Call | | ----------- | ------------------------------- | ---------------------------------------- | | 100 | Continue | http.statusContinue | | 101 | Switching Protocols | http.statusSwitchingProtocols | | 102 | Processing | http.statusProcessing | | 103 | Early Hints | http.statusEarlyHints | | 200 | OK | http.statusOk | | 201 | Created | http.statusCreated | | 202 | Accepted | http.statusAccepted | | 203 | Non-Authoritative Information | http.statusNonAuthoritativeInformation | | 204 | No Content | http.statusNoContent | | 205 | Reset Content | http.statusResetContent | | 206 | Partial Content | http.statusPartialContent | | 207 | Multi-Status | http.statusMultiStatus | | 208 | Already Reported | http.statusAlreadyReported | | 226 | IM Used | http.statusIMUsed | | 300 | Multiple Choices | http.statusMultipleChoices | | 301 | Moved Permanently | http.statusMovedPermanently | | 302 | Found | http.statusFound | | 303 | See Other | http.statusSeeOther | | 304 | Not Modified | http.statusNotModified | | 305 | Use Proxy | http.statusUseProxy | | 307 | Temporary Redirect | http.statusTemporaryRedirect | | 308 | Permanent Redirect | http.statusPermanentRedirect | | 400 | Bad Request | http.statusBadRequest | | 401 | Unauthorized | http.statusUnauthorized | | 402 | Payment Required | http.statusPaymentRequired | | 403 | Forbidden | http.statusForbidden | | 404 | Not Found | http.statusNotFound | | 405 | Method Not Allowed | http.statusMethodNotAllowed | | 406 | Not Acceptable | http.statusNotAcceptable | | 407 | Proxy Authentication Required | http.statusProxyAuthenticationRequired | | 408 | Request Timeout | http.statusRequestTimeout | | 409 | Conflict | http.statusConflict | | 410 | Gone | http.statusGone | | 411 | Length Required | http.statusLengthRequired | | 412 | Precondition Failed | http.statusPreconditionFailed | | 413 | Payload Too Large | http.statusPayloadTooLarge | | 414 | URI Too Long | http.statusURITooLong | | 415 | Unsupported Media Type | http.statusUnsupportedMediaType | | 416 | Range Not Satisfiable | http.statusRangeNotSatisfiable | | 417 | Expectation Failed | http.statusExpectationFailed | | 418 | I'm a teapot | http.statusImATeapot | | 421 | Misdirected Request | http.statusMisdirectedRequest | | 422 | Unprocessable Entity | http.statusUnprocessableEntity | | 423 | Locked | http.statusLocked | | 424 | Failed Dependency | http.statusFailedDependency | | 425 | Too Early | http.statusTooEarly | | 426 | Upgrade Required | http.statusUpgradeRequired | | 428 | Precondition Required | http.statusPreconditionRequired | | 429 | Too Many Requests | http.statusTooManyRequests | | 431 | Request Header Fields Too Large | http.statusRequestHeaderFieldsTooLarge | | 451 | Unavailable For Legal Reasons | http.statusUnavailableForLegalReasons | | 500 | Internal Server Error | http.statusInternalServerError | | 501 | Not Implemented | http.statusNotImplemented | | 502 | Bad Gateway | http.statusBadGateway | | 503 | Service Unavailable | http.statusServiceUnavailable | | 504 | Gateway Timeout | http.statusGatewayTimeout |

If you encounter any issues or would like to contribute to this package, feel free to open an issue or submit a pull request.

License

This package is open source and available under the MIT License.