router-http 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +8 -4
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "router-http",
3
3
  "description": "Simple HTTP router compatible with Express",
4
4
  "homepage": "https://github.com/Kikobeats/router-http",
5
- "version": "1.0.9",
5
+ "version": "1.0.10",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
package/src/index.js CHANGED
@@ -100,12 +100,16 @@ class Router extends Trouter {
100
100
  const loop = () =>
101
101
  res.writableEnded ||
102
102
  (index < size &&
103
- (() => {
103
+ (async () => {
104
104
  try {
105
105
  const mware = middlewares[index++]
106
- return index === size
107
- ? mware(undefined, req, res, next)
108
- : mware(req, res, next)
106
+ const result =
107
+ index === size
108
+ ? mware(undefined, req, res, next)
109
+ : mware(req, res, next)
110
+ if (result && typeof result.then === 'function') {
111
+ await result
112
+ }
109
113
  } catch (err) {
110
114
  return this.unhandler(err, req, res, next)
111
115
  }