Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middy http-router not working in ES5 #1033

Closed
nareshprajapatitatva opened this issue Mar 15, 2023 · 1 comment
Closed

Middy http-router not working in ES5 #1033

nareshprajapatitatva opened this issue Mar 15, 2023 · 1 comment
Labels

Comments

@nareshprajapatitatva
Copy link

TypeError: httpRouterHandler is not a function
Getting TypeError error when using http-router in ES5 .js file.

To Reproduce

Here is the sample code

const httpRouterHandler = require('@middy/http-router');

const getHandler = middy().handler((event, context) => {
  console.log('call from route');
  return {
    statusCode: 200,
    body: '{}'
  };
});

const routes = [
  {
    method: 'GET',
    path: '/health',
    handler: getHandler
  }
];

exports.health = middy().handler(httpRouterHandler(routes));

Thrown error
image

Expected behaviour
It should call given route instead of giving an error

Environment (please complete the following information):

  • Node.js: nodejs16.x
  • Middy: 4.1.0
  • AWS SDK: 2.1293.0
@willfarrell
Copy link
Member

Thanks for reporting, I've updated the dep and added in new tests. Seems to have resolved itself. See v4.2.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants