@brunocarvalho/error-handler
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

error-handler

A error handler for express APIs applications.

Installation

$ npm install --save @brunocarvalho/error-handler

usage

import express from 'express'
import errorHandler, { type RequestError } from '@brunocarvalho/error-handler'

const app = express()

app.get('/', (req, res) => {
  const err: RequestError = new Error('Not Found')
  err.reason = `item not found in database`
  err.statusCode = 404
  throw err
})

app.use(errorHandler())

Readme

Keywords

none

Package Sidebar

Install

npm i @brunocarvalho/error-handler

Weekly Downloads

21

Version

0.3.2

License

MIT

Unpacked Size

10.8 kB

Total Files

7

Last publish

Collaborators

  • brunocarvalhodearaujo