Skip to content

Commit

Permalink
Merge branch 'release/5.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Feb 8, 2018
2 parents 39fe3ff + 6aa16b3 commit 16370e5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="5.0.4"></a>
## [5.0.4](https://github.com/adonisjs/adonis-framework/compare/v5.0.3...v5.0.4) (2018-02-08)


### Bug Fixes

* **server:** allow named middleware to be used multiple times ([b1d04ef](https://github.com/adonisjs/adonis-framework/commit/b1d04ef))



<a name="5.0.3"></a>
## [5.0.3](https://github.com/adonisjs/adonis-framework/compare/v5.0.2...v5.0.3) (2018-02-08)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adonisjs/framework",
"version": "5.0.3",
"version": "5.0.4",
"description": "Adonis framework makes it easy for you to write webapps with less code",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ class Server {
throw GE.RuntimeException.invoke(missingNamedMiddleware(name), 500, 'E_MISSING_NAMED_MIDDLEWARE')
}

packet.params = args
return packet
return {
namespace: packet.namespace,
params: args
}
})
}

Expand Down
29 changes: 29 additions & 0 deletions test/unit/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,4 +978,33 @@ test.group('Server | Calls', (group) => {

assert.equal(handler, 'App/Exceptions/Handler')
})

test('use same named middleware twice with different params', async (assert) => {
class AppMiddleware {
async handle (ctx, next, [id]) {
ctx.ids = ctx.ids || []
ctx.ids.push(id)
await next()
}
}

ioc.fake('Middleware/AppMiddleware', function () {
return new AppMiddleware()
})

Route.get('/', async function ({ ids }) {
return ids
})
.middleware('app:1')
.middleware('app:2')

this.server.registerNamed({
'app': 'Middleware/AppMiddleware'
})

const app = http.createServer(this.server.handle.bind(this.server))

const res = await supertest(app).get('/').expect(200)
assert.deepEqual(res.body, ['1', '2'])
})
})

0 comments on commit 16370e5

Please sign in to comment.