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

Support for async/await #51

Merged
merged 6 commits into from
Nov 19, 2017
Merged

Support for async/await #51

merged 6 commits into from
Nov 19, 2017

Conversation

lmammino
Copy link
Member

@lmammino lmammino commented Nov 18, 2017

Closes #49 and #50

This will add support for returning promises (instead of invoking the next callback) and making possible to use async middlewares.

More documentation and examples are coming soon.

TODO:

  • Documentation & examples
  • Increase coverage
  • Fix tests (babel transpile async/await)

Now ready for review

Copy link
Contributor

@techfort techfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff sir!

@codecov
Copy link

codecov bot commented Nov 19, 2017

Codecov Report

Merging #51 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #51   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           9     10    +1     
  Lines         142    157   +15     
  Branches       31     36    +5     
=====================================
+ Hits          142    157   +15
Impacted Files Coverage Δ
src/__tests__/middy.js 100% <ø> (ø) ⬆️
src/__tests__/isPromise.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74b9e2e...0550bee. Read the comment docs.

@lmammino lmammino changed the title [WIP] Support for async/await Support for async/await Nov 19, 2017
@lmammino
Copy link
Member Author

This is now ready for review, please have a look and let me know what you think!

CC: @acambas @techfort @peterjcaulfield @padraigobrien @dkatavic
Also BCC: @coreylight, feel free to provide feedback.

Copy link
Contributor

@dkatavic dkatavic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Just have some comments about typos and undeleted comment

src/middy.js Outdated
@@ -79,7 +93,23 @@ const runErrorMiddlewares = (middlewares, instance, done) => {
const nextMiddleware = stack.shift()

if (nextMiddleware) {
return nextMiddleware(instance, runNext)
// return nextMiddleware(instance, runNext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

README.md.hb Outdated
Middy supports middlewares that return promises instead that directly calling the callback:

```javascript
const asyncValiator = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncValiator to asyncValidator

README.md.hb Outdated
Thanks to this behaviour you can define middlewares using `async` functions:

```javascript
const asyncValiator = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncValidator

README.md.hb Outdated
}
}

handler.use(asyncValidator)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handler.use(asyncValidator)

@lmammino
Copy link
Member Author

Thanks, @dkatavic for the thorough review. I made the suggested changes.

@lmammino lmammino merged commit a700f93 into master Nov 19, 2017
@lmammino lmammino deleted the feature/support-async-await branch November 19, 2017 21:48
@lmammino lmammino mentioned this pull request Nov 19, 2017
@coreylight
Copy link

Very cool!

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

Successfully merging this pull request may close these issues.

None yet

4 participants