8000 Handle middleware passed after the service to app.use by dbkaplun · Pull Request #178 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content

Handle middleware passed after the service to app.use#178

Merged
daffl merged 3 commits intofeathersjs:masterfrom
dbkaplun:post-service-middleware
Dec 2, 2015
Merged

Handle middleware passed after the service to app.use#178
daffl merged 3 commits intofeathersjs:masterfrom
dbkaplun:post-service-middleware

Conversation

@dbkaplun
Copy link
@dbkaplun dbkaplun commented Dec 1, 2015

Closes #176

Copy link
Member

Choose a reason for hiding this comment

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

Small style nit, I'd make it

if (parts[1].length > 1) {
  throw new Error('more than one service passed to app.use');
}

@daffl
Copy link
Member
daffl commented Dec 1, 2015

Awesome, thank you! I made some comments and it would be nice to have some tests for this functionality (probably similar to https://github.com/feathersjs/feathers/blob/master/test/providers/rest.test.js#L337).
After that we can definitely get it into the new release!

@dbkaplun
Copy link
Author
dbkaplun commented Dec 1, 2015

@daffl fixed and added tests

Copy link
Member

Choose a reason for hiding this comment

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

I think we could set and then check for res.data.postService instead since the handler should run last.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry I don't understand, can you rephrase please?

Copy link
Member

Choose a reason for hiding this comment

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

What I mean is to instead set something like:

res.data.postService = true;

and then in the test check for

assert.ok(data.postService, 'Post-service middleware updated response');

instead of assert.equal(response.headers['post-service'], 'dishes', 'Post-service middleware updated response');.

Copy link
Author

Choose a reason for hiding this comment

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

I see. I did it this way because I wanted to ensure that the post-service handler actually runs after the service, but I can change it if you like.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. Lets leave it then. I will merge shortly. Thanks again!

@daffl
Copy link
Member
daffl commented Dec 1, 2015

This is great! Thank you! One more small comment for the test. Nothing major but then we can get it in and ready for a version 1.3.

@daffl daffl added this to the 1.3.0 milestone Dec 1, 2015
daffl added a commit that referenced this pull request Dec 2, 2015
Handle middleware passed after the service to app.use
@daffl daffl merged commit b7b0664 into feathersjs:master Dec 2, 2015
@dbkaplun dbkaplun deleted the post-service-middleware branch December 2, 2015 15:57
@ekryski
Copy link
Contributor
ekryski commented Dec 15, 2015

Oh nice! This PR snuck by me but I've run into this before. Thanks @dbkaplun!

daffl pushed a commit that referenced this pull request Aug 25, 2018
* Add .idea/

* Update _gitignore

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0