UNPKG
api-problem
Version:
latest (9.0.2)
9.0.2
9.0.1
9.0.0
8.0.0
7.0.4
7.0.3
7.0.2
7.0.1
7.0.0
6.1.4
6.1.3
6.1.2
6.1.1
6.1.0
6.0.1
6.0.0
5.1.2
5.1.1
5.1.0
5.0.1
5.0.0
4.0.0
3.0.0
2.0.3
2.0.2
2.0.1
2.0.0
1.1.0
1.0.0
HTTP Problem Utility
github.com/ahmadnassri/api-problem
ahmadnassri/node-api-problem
api-problem
/
lib
/
middleware.js
12 lines
(10 loc)
•
233 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
const
Problem
=
require
(
'./index'
)
module
.
exports
=
function
Middleware
(
space
) {
return
(
err, req, res, next
) =>
{
if
(err
instanceof
Problem
) { err.
send
(res, space ||
null
) }
else
{
return
next
() } } }