I am using the middy package from npm. I need someone to tell me how to write the following code using module.exports
export default handler => middy(handler)
.use([
httpBodyParser,
httpEventNormalizer,
httpErrorHandler
])
The function above is anonymous which takes a handler function and wraps the middleware around it. How to write this using module.exports? Please help me!!
"latest JavaScript" wouldn't use
module.exportsat all, it would useexportas the code shippet shown does. If the question is really how to do this the old CommonJS way, you'd do it by assigning tomodule.exportsdirectly:But if possible, I'd use standard JavaScript modules ("ECMAScript Modules" aka "ESM" — i.e.,
exportandimport) instead.