Skip to content

Commit

Permalink
wqFixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino committed Nov 19, 2017
1 parent 4734a3f commit cb94a34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ If no middleware manages the error, the lambda execution fails reporting the unm
Middy supports middlewares that return promises instead that directly calling the callback:

```javascript
const asyncValiator = () => {
const asyncValidator = () => {
before: (handler) => {
if (handler.event.body) {
return new Promise((resolve, reject) => {
Expand All @@ -266,13 +266,13 @@ const asyncValiator = () => {
}
}

handler.use(asyncValidator)
handler.use(asyncValidator())
```

Thanks to this behaviour you can define middlewares using `async` functions:

```javascript
const asyncValiator = () => {
const asyncValidator = () => {
before: async (handler) => {
if (handler.event.body) {
return await asyncValidate(handler.event.body)
Expand All @@ -282,7 +282,7 @@ const asyncValiator = () => {
}
}

handler.use(asyncValidator)
handler.use(asyncValidator())
```

Of course, since AWS lambda runs on Node.js 6.10, you will need to transpile your `async/await` code (e.g. using [babel](https://babeljs.io/)).
Expand Down
8 changes: 4 additions & 4 deletions README.md.hb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ If no middleware manages the error, the lambda execution fails reporting the unm
Middy supports middlewares that return promises instead that directly calling the callback:
```javascript
const asyncValiator = () => {
const asyncValidator = () => {
before: (handler) => {
if (handler.event.body) {
return new Promise((resolve, reject) => {
Expand All @@ -266,13 +266,13 @@ const asyncValiator = () => {
}
}
handler.use(asyncValidator)
handler.use(asyncValidator())
```
Thanks to this behaviour you can define middlewares using `async` functions:
```javascript
const asyncValiator = () => {
const asyncValidator = () => {
before: async (handler) => {
if (handler.event.body) {
return await asyncValidate(handler.event.body)
Expand All @@ -282,7 +282,7 @@ const asyncValiator = () => {
}
}
handler.use(asyncValidator)
handler.use(asyncValidator())
```
Of course, since AWS lambda runs on Node.js 6.10, you will need to transpile your `async/await` code (e.g. using [babel](https://babeljs.io/)).
Expand Down
1 change: 0 additions & 1 deletion src/middy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const runErrorMiddlewares = (middlewares, instance, done) => {
const nextMiddleware = stack.shift()

if (nextMiddleware) {
// return nextMiddleware(instance, runNext)
const retVal = nextMiddleware(instance, runNext)

if (retVal) {
Expand Down

0 comments on commit cb94a34

Please sign in to comment.