1.0.0 • Published 4 years ago

http-response-status-codes v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

http-response-status-codes

Constants for standard HTTP response status codes that indicate whether a specific HTTP request has been successfully completed.

Based on MDN web docs.

Installation

npm i http-response-status-codes

Usage (express.js example)

const HTTP_STATUS = require('http-response-status-codes');

app.get('/ping', (req, res) => {
  res.status(HTTP_STATUS.SUCCESS.OK).send('Pong');
});

app.get('/account', (req, res) => {
  res.status(HTTP_STATUS.CLIENT.UNAUTHORIZED).send('Pong');
});

app.get('/calculate', (req, res) => {
  res.status(HTTP_STATUS.SERVER.INTERNAL_SERVER_ERROR).send('Pong');
});

Codes