Gathering detailed insights and metrics for middy-middleware-json-error-handler
Gathering detailed insights and metrics for middy-middleware-json-error-handler
Gathering detailed insights and metrics for middy-middleware-json-error-handler
Gathering detailed insights and metrics for middy-middleware-json-error-handler
A middy middleware that returns errors as http errors, compatible with http-errors.
npm install middy-middleware-json-error-handler
Typescript
Module System
Node Version
NPM Version
81.8
Supply Chain
84.4
Quality
75.8
Maintenance
100
Vulnerability
99.6
License
TypeScript (83.98%)
JavaScript (16.02%)
Total Downloads
552,613
Last Day
420
Last Week
4,983
Last Month
20,388
Last Year
214,531
MIT License
30 Stars
416 Commits
6 Forks
2 Watchers
7 Branches
4 Contributors
Updated on Mar 31, 2025
Minified
Minified + Gzipped
Latest Version
4.0.0
Package Id
middy-middleware-json-error-handler@4.0.0
Unpacked Size
15.84 kB
Size
5.81 kB
File Count
18
NPM Version
8.11.0
Node Version
16.16.0
Published on
Jul 26, 2023
Cumulative downloads
Total Downloads
Last Day
1.9%
420
Compared to previous day
Last Week
3.5%
4,983
Compared to previous week
Last Month
2.2%
20,388
Compared to previous month
Last Year
7.8%
214,531
Compared to previous year
3
1
41
A middy middleware that returns errors as http errors, compatible with http-errors.
Download node at nodejs.org and install it, if you haven't already.
1npm install middy-middleware-json-error-handler --save
There is additional documentation.
1import middy from '@middy/core' 2import JSONErrorHandlerMiddleware from 'middy-middleware-json-error-handler' 3import createHttpError from 'http-errors' 4import { APIGatewayEvent } from 'aws-lambda' 5 6// This is your AWS handler 7async function helloWorld (event: APIGatewayEvent) { 8 if (event.queryStringParameters?.search == null) { 9 // If you throw an error with status code, the error will be returned as stringified JSON. 10 // Only the stack will be omitted. 11 throw createHttpError(400, 'Query has to include a search') 12 } 13 14 if (event.queryStringParameters?.search === 'error') { 15 // If you throw an error with status code greater than 500 and specify in options that the error 16 // must be exposed, then the error will be returned as stringified JSON 17 throw createHttpError(500, 'Something went wrong', { expose: true }) 18 } 19 20 // If you throw an error with no status code, only a generic message will be shown to the user 21 // instead of the full error 22 throw new Error('Search is not implemented yet') 23} 24 25// Specify which are the error properties to omit in response (by default, only the stack is omitted) 26const options = { 27 errorPropertiesToOmit: ['name', 'statusCode', 'stack'] 28} 29 30// Let's "middyfy" our handler, then we will be able to attach middlewares to it (options parameter is optional) 31export const handler = middy(helloWorld) 32 .use(JSONErrorHandlerMiddleware(options)) // This middleware is needed do handle the errors thrown by the handler
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More