Coder Social home page Coder Social logo

joserfjuniorllms / node-http-status Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adaltas/node-http-status

0.0 0.0 0.0 244 KB

Utility to interact with HTTP status code in Node.js

Home Page: http://www.adaltas.com/projects/node-http-status/

License: Other

Makefile 6.14% CoffeeScript 93.86%

node-http-status's Introduction

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

  var HTTPStatus = require('http-status');

  // Print "Internal Server Error"
  console.log(HTTPStatus[500]);

  // Print 500
  console.log(HTTPStatus.INTERNAL_SERVER_ERROR);

Express sample

  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);

Contributors

node-http-status's People

Contributors

gasi avatar iandotkelly avatar jamsesso avatar johdougss avatar wdavidw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.