Socket
Socket
Sign inDemoInstall

koa-error-ejs

Package Overview
Dependencies
10
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-error-ejs

Error reponses (text, json, html) for koa and EJS


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

koa-error-ejs

Error response middleware for koa supporting:

  • text

  • json

  • html

    Based on koa-error, adapter to use EJS as view

Installation

$ npm install koa-error

and then copy the default error view to your views folder

$ cp node_modules/koa-error-ejs/error.html views/

Options

  • view String path to template written with ejs. Defaults to {view.root}/error
  • layout String|Boolean layout to use on error view, or false if none. Defaults to false.
  • custom Object specific view for a status code, for example: {404: 'error/not-found'}. Defaults to {}

Custom templates

By using the view option you can override the bland default template, with the following available local variables:

  • env
  • ctx
  • request
  • response
  • error
  • stack
  • status
  • code

Here's an example:

<!DOCTYPE html>
<html>
  <head>
    <title>Error - <%=status%></title>
  </head>
  <body>
    <div id="error">
      <h1>Error</h1>
      <p>Looks like something broke!</p>
      <% if(env === 'development'){ %>
      <pre>
        <code>
	  <%-stack%>
        </code>
      </pre>
      <% } %>
    </div>
  </body>
</html>

License

MIT

Keywords

FAQs

Last updated on 29 Jun 2014

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc