Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
},
required: ['body']
}
}
/* Export inputSchema & outputSchema for automatic documentation */
exports.schema = schema
exports.handler = middy(businessLogic)
.use(httpHeaderNormalizer())
// parses the request body when it's a JSON and converts it to an object
.use(jsonBodyParser())
// validates the input
.use(validator({ inputSchema: schema.input }))
// handles common http errors and returns proper responses
.use(httpErrorHandler())
Object.keys(exports).forEach(key => {
module.exports[key] = middy(exports[key])
.use(
loggerMiddleware({
logger: log
})
)
.use(httpEventNormalizer())
.use(jsonBodyParser())
.use(validator({ inputSchema: exports[key].schema }))
.use(cors())
.use(autoProxyResponse())
.use(httpErrorHandler())
})
}