I have a Typescript Lambda set up like so:
import { APIGatewayProxyHandler } from 'aws-lambda'
import middy from '@middy/core'
import cors from '@middy/http-cors'
import httpJsonBodyParser from '@middy/http-json-body-parser'
import jsonapi from 'middy-jsonapi'
import validator from '@middy/validator'
import httpContentNegotiation from '@middy/http-content-negotiation'
const main: APIGatewayProxyHandler = async (event) => {
...
}
export const handler = middy(main)
.use(httpJsonBodyParser())
.use(cors())
.use(jsonapi({ response }))
.use(
httpContentNegotiation({
availableLanguages: ['en-US'],
availableMediaTypes: ['application/vnd.api+json'],
})
)
.use(validator({ inputSchema }))
But when I send an invalid payload to it, I get a 500 back instead of a 400. I've traced the error to line 72 of index.js. The error class is BadRequestError, but handler.error instanceof createError.BadRequest evaluates to false. Not sure where to take it from there, otherwise I'd whip up a PR.
I have a Typescript Lambda set up like so:
But when I send an invalid payload to it, I get a 500 back instead of a 400. I've traced the error to line 72 of index.js. The error class is
BadRequestError, buthandler.error instanceof createError.BadRequestevaluates to false. Not sure where to take it from there, otherwise I'd whip up a PR.