Skip to content

Repository files navigation

Build Status

HTTP Status code for Node

Utility to interact with HTTP status code.

Usage

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.

API

This module is very simple. A documentation would be more complicate than reading the original code.

API sample

varHTTPStatus=require('http-status');// Print "Internal Server Error"console.log(HTTPStatus[500]);// Print 500console.log(HTTPStatus.INTERNAL_SERVER_ERROR);

Express sample

varexpress=require('express'),redis=require('redis'),HTTPStatus=require('http-status');varapp=express.createServer();app.get('/',function(req,res){varclient=redis.createClient();client.ping(function(err,msg){if(err){returnres.send(HTTPStatus.INTERNAL_SERVER_ERROR);}res.send(msg,HTTPStatus.OK);});});app.listen(3000);

Contributors

About

Utility to interact with HTTP status code in Node.js

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages