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
TypeScript (83.98%)
JavaScript (16.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
30 Stars
416 Commits
6 Forks
2 Watchers
7 Branches
4 Contributors
Updated on Mar 31, 2025
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
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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 binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
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
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
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-07-07
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