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

restberry-errors

v1.0.2

Published

Restberry HTTP error handler

Downloads

3

Readme

Restberry-Errors

Restberry HTTP error handler.

Install

npm install restberry-errors

Usage

var errors = require('restberry-errors');

var err = {message: 'An error happened...'};
new errors.BadRequest(err, function(err) {
    console.log(err);
    // {
    //   error: {
    //      statusCode: 400,
    //      property: '',
    //      title: 'Bad Request',
    //      message: 'An error happened...',
    //      devMessage: '<{message: \'An error happened...\'}>'
    //   },
    // }
});

Response examples

  • 400 BAD REQUEST
2014-09-07T21:01:05.365Z|127.0.0.1|POST|/api/v1/users/540cc791ee94cdb74098beef|<{
  "email": "[email protected]",
  "password": "**********"
}>
2014-09-07T21:01:05.367Z|127.0.0.1|400|<{
  "error": {
    "statusCode": 400,
    "property": "",
    "title": "Bad Request",
    "message": "Invalid password, needs to be at lest 8 characters long",
    "devMessage": "Requested <POST> </api/v1/users/540cc791ee94cdb74098beef> with data <{\"email\": \"[email protected]\", \"password\":\"**********\"}>."
  }
}>
  • 401 UNAUTHORIZED
2014-05-11T13:26:27.758Z|172.16.122.129|GET|/api/v1/foos/536f7a835bc82212a9e78624|<{}>
2014-05-11T13:26:27.758Z|172.16.122.129|401|<{
  "error": {
    "statusCode": 401,
    "property": "",
    "title": "Unauthorized",
    "message": "Need to be logged in to perform this action.",
    "devMessage": "Requested <GET> </api/v1/foos/536f7a835bc82212a9e78624> with data <{}>. Make sure you are logged in and authenticated."
  }
}>
  • 403 FORBIDDEN
2014-05-11T13:26:27.758Z|172.16.122.129|GET|/api/v1/foos/536f7a835bc82212a9e78624|<{}>
2014-05-11T13:26:27.758Z|172.16.122.129|403|<{
  "error": {
    "statusCode": 403,
    "property": "",
    "title": "Forbidden",
    "message": "You are not authorized!",
    "devMessage": "Requested <GET> </api/v1/foos/536f7a835bc82212a9e78624> with data <{}>. Make sure you're logged in with the correct credentials."
  }
}>
  • 409 CONFLICT
2014-05-11T11:55:55.368Z|172.16.122.129|POST|/api/v1/foos|<{
  "name": "test"
}>
2014-05-11T11:55:55.358Z|172.16.122.129|409|<{
  "error": {
    "statusCode": 409,
    "property": "foo",
    "title": "Conflict",
    "message": "There already exists a 'foo' object with these properties.",
    "devMessage": "Requested <POST> </api/v1/foos> with data <{\"name\":\"test\"}>.'
  }
}>
  • 500 SERVER ISSUE
2014-05-11T13:23:37.820Z|172.16.122.129|POST|/api/v1/foos|<{
  "name": "test"
}>
2014-05-11T13:23:37.821Z|172.16.122.129|500|<{
  "error": {
    "statusCode": 500,
    "property": "",
    "title": "Server Issue",
    "message": "We're on it!",
    "devMessage": "Requested <POST> </api/v1/bars> with data <{\"name\":\"test\"}>."
  }
}>

Run the tests

npm test