All Projects → futurestudio → hapi-dev-errors

futurestudio / hapi-dev-errors

Licence: MIT License
A hapi plugin to return better error details and skip the look at command line to catch the issue.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hapi-dev-errors

Takeoff
A rapid development environment using docker for convenience.
Stars: ✭ 271 (+367.24%)
Mutual labels:  development, hapi, developer-tools
hapi-statsd
A hapi plugin for sending request round trip metrics to statsd
Stars: ✭ 29 (-50%)
Mutual labels:  hapi, hapi-plugin
hapi-plugin-mysql
Hapi plugin for MySQL
Stars: ✭ 17 (-70.69%)
Mutual labels:  hapi, hapi-plugin
hapi-mongo-models
📦 A hapi plugin for `mongo-models`
Stars: ✭ 101 (+74.14%)
Mutual labels:  hapi, hapi-plugin
Devutils App
Offline Toolbox for Developers
Stars: ✭ 2,735 (+4615.52%)
Mutual labels:  productivity, developer-tools
hapi-docs
Beautiful API documentation generator for Hapi using Vue
Stars: ✭ 64 (+10.34%)
Mutual labels:  hapi, hapi-plugin
hapi-now-auth
Hapi token auth for bearer and jwt
Stars: ✭ 43 (-25.86%)
Mutual labels:  hapi, hapi-plugin
Check It Out
A command line interface for Git Checkout. See branches available for checkout.
Stars: ✭ 127 (+118.97%)
Mutual labels:  productivity, developer-tools
android-trinity
android-trinity is tiny proactive framework with much of the scaffolding code required to start a new Android Application.
Stars: ✭ 44 (-24.14%)
Mutual labels:  development, developer-tools
hapi-sentry
A hapi plugin for request error logging to Sentry
Stars: ✭ 24 (-58.62%)
Mutual labels:  hapi, hapi-plugin
dotfiles
My personal app/env configs and dotfiles.
Stars: ✭ 27 (-53.45%)
Mutual labels:  development, developer-tools
Dev Tools
The most popular software developer tools in one app
Stars: ✭ 221 (+281.03%)
Mutual labels:  productivity, developer-tools
Cutcode
A browser extension that enables double click to copy code snippet from stack overflow.
Stars: ✭ 163 (+181.03%)
Mutual labels:  productivity, developer-tools
nodejs-tutorials-hapi
Examples for the hapi tutorial series within the Future Studio University
Stars: ✭ 70 (+20.69%)
Mutual labels:  hapi, future-studio-university
Duckrails
Development tool to mock API endpoints quickly and easily (docker image available)
Stars: ✭ 1,690 (+2813.79%)
Mutual labels:  productivity, developer-tools
hapi-good-winston
A good reporter to send and log events with winston
Stars: ✭ 21 (-63.79%)
Mutual labels:  hapi, hapi-plugin
knowledge-base-content
Open-source knowledge base covering topics about developer experience.
Stars: ✭ 73 (+25.86%)
Mutual labels:  productivity, development
Bloop
Bloop is a build server and CLI tool to compile, test and run Scala fast from any editor or build tool.
Stars: ✭ 730 (+1158.62%)
Mutual labels:  productivity, developer-tools
Gita
Manage many git repos with sanity 从容管理多个git库
Stars: ✭ 865 (+1391.38%)
Mutual labels:  productivity, developer-tools
alfred-string-operations
Perform string operations to clipboard content
Stars: ✭ 70 (+20.69%)
Mutual labels:  productivity, development
hapi-dev-errors logo

A hapi plugin to show server errors in the browser or terminal.


Installation · Usage · Plugin Options



Build Status Known Vulnerabilities Latest Version Monthly downloads

Follow @marcuspoehls for updates!


Development of this hapi plugin is supported by Future Studio University 🚀
Join the Future Studio University and Skyrocket in Node.js


Introduction

A hapi plugin to return an error view for web requests, providing more details of the issue. hapi-dev-errors will give you the exact file where the error happend and a nice error stacktrace within the browser. Skip the extra look at your command line to catch the issue's location.

hapi-dev-errors default error Youch error view

hapi-dev-errors seamlessly integrates Youch to show the error details.

Besides the web view, hapi-dev-errors prints pretty error details to the terminal. This is nice when running your hapi server as an API. Printing error details to the console is enabled by default. To disable the terminal error, use the toTerminal: false option.

hapi-dev-errors pretty terminal error

Requirements

This plugin uses async/await which requires Node.js v12 or newer.

Compatibility

Major Release hapi.js version Node.js version
v4 >=17 hapi >=12
v3 >=17 hapi >=8
v2 >=17 hapi >=8

Installation

Add hapi-dev-errors as a dependency to your project:

npm i hapi-dev-errors

Using hapi v17 or v18?

Use the 3.x release of hapi-dev-errors:

npm i hapi-dev-errors@3

Using hapi v16 (or lower)?

Use the 1.3.2 release of hapi-dev-errors with hapi v16. Later versions are only compatible with hapi v17.

Examples

Check out the examples directory and get an impression on how to configure hapi-dev-errors with the individual plugins options and how to customize the error view.

Usage

hapi-dev-errors is disabled by default to avoid leaking sensitive error details during production.

Enable the plugin by define a "truthy" value for the showErrors option.

The most straight forward way to register the hapi-dev-errors plugin:

await server.register({
    plugin: require('hapi-dev-errors'),
    options: {
      showErrors: process.env.NODE_ENV !== 'production'
    }
})

// went smooth like chocolate :)

Plugin Registration Options

The following plugin options allow you to customize the default behavior of hapi-dev-errors:

  • showErrors: (boolean), default: false — by default, the plugin is disabled and keeps hapi's default error handling behavior
  • template: (string), no default — provide the template name that you want to render with h.view(template, errorData)
  • toTerminal: (boolean), default: true — print pretty errors to the terminal as well (enabled by default)
  • links: (array) - default: linked SVG icons for Google and Stack Overflow - an array of callback functions that accept the error as a parameter. The callback functions should return the link to render below the error message. Pass an empty array [] to disable the default links
await server.register({
    plugin: require('hapi-dev-errors'),
    options: {
        showErrors: process.env.NODE_ENV !== 'production',
        template: 'my-error-view',
        toTerminal: true,
        links: [ (error) => {
          return `
            <a href="https://github.com/futurestudio/hapi-dev-errors/search?q=${error.message}">
              Search hapi-dev-errors on GitHub
            </a>
          `
        }
      ]
    }
})

// went smooth like chocolate :)

Provided Values for Your Custom Error View

hapi-dev-errors supports the template option while registering the plugin. Provide a template name to use your personal error template and not the default one shipped with hapi-dev-errors. In case you pass a string value for the template name, the view will be rendered with h.view(template, errorData).code(500).

Available properties to use in your custom error view:

  • request: the request that caused the error
  • error: the error response with all its properties
  • title: error title like Internal Server Error
  • statusCode: HTTP response status code (always 500)
  • message: error message, like Uncaught error: h.view(...).test is not a function
  • method: HTTP request method, like GET
  • url: URL request path, like /signup
  • headers: HTTP request headers object, in key-value format
  • payload: HTTP request payload, only available for HTTP methods other than GET, in key-value format
  • stacktrace: error stacktrace

Feature Requests

Do you miss a feature? Please don’t hesitate to create an issue with a short description of your desired addition to this plugin.

Links & Resources

Contributing

  1. Create a fork
  2. Create your feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 🚀

License

MIT © Future Studio


futurestud.io  ·  GitHub @futurestudio  ·  Twitter @futurestud_io

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].