![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
http-status
Advanced tools
The http-status npm package provides a collection of HTTP status codes and their associated messages. It is useful for setting and interpreting HTTP response statuses in web applications.
Accessing Status Codes
You can easily access standard HTTP status codes using the package. This is useful for setting response statuses in your web server.
const httpStatus = require('http-status');
console.log(httpStatus.OK); // 200
console.log(httpStatus.NOT_FOUND); // 404
Accessing Status Messages
The package allows you to retrieve the standard message associated with a given status code. This can be useful for logging or displaying human-readable status messages.
const httpStatus = require('http-status');
console.log(httpStatus['200']); // 'OK'
console.log(httpStatus['404']); // 'Not Found'
Custom Status Codes
You can add custom status codes and messages to the http-status object. This is useful if your application uses non-standard status codes.
const httpStatus = require('http-status');
httpStatus['999'] = 'Custom Status';
console.log(httpStatus['999']); // 'Custom Status'
The statuses package provides similar functionality by offering a list of HTTP status codes and their associated messages. It also allows for custom status codes and messages. Compared to http-status, statuses is more lightweight and focuses solely on status codes and messages without additional features.
The http-errors package is used to create HTTP error objects with status codes and messages. It provides more advanced error handling capabilities compared to http-status, including the ability to create custom error classes. It is useful for applications that need detailed error handling and reporting.
Utility to interact with HTTP status code.
Once you require this module, you may call it with either an HTTP code or a message name. With an HTTP code, you will get the message name while with a message name you will get an HTTP code. Simple.
This module is very simple. A documentation would be more complicate than reading the original code.
var HTTPStatus = require('http-status');
// Print "Internal Server Error"
console.log(HTTPStatus[500]);
// Print 500
console.log(HTTPStatus.INTERNAL_SERVER_ERROR);
var express = require('express'),
redis = require('redis'),
HTTPStatus = require('http-status');
var app = express.createServer();
app.get('/', function (req, res) {
var client = redis.createClient();
client.ping(function (err, msg) {
if (err) {
return res.send(HTTPStatus.INTERNAL_SERVER_ERROR);
}
res.send(msg, HTTPStatus.OK);
});
});
app.listen(3000);
FAQs
Interact with HTTP status code
The npm package http-status receives a total of 0 weekly downloads. As such, http-status popularity was classified as not popular.
We found that http-status demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.