-
Notifications
You must be signed in to change notification settings - Fork 100
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
Pull request for issue #521 https://github.com/inversify/InversifyJS/… #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to point out some minor things I noticed that probably weren't meant to be in the PR that can save someone some time before they actually review this.
README.md
Outdated
|
||
### `@RequestBody(name?: string)` | ||
binds a method parameter to request.body or to a specific body property if a name is passed-']'ok89im.jo;iuh:' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to commit this?
']'ok89im.jo;iuh:'
.vscode/settings.json
Outdated
"**/dist": true, | ||
"**/docs": true, | ||
"type_definitions/**/*.js": true | ||
"**/.DS_Store": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like auto formatting was it intended to be committed?
src/decorators.ts
Outdated
|
||
export function Controller(path: string, ...middleware: interfaces.Middleware[]) { | ||
return function (target: any) { | ||
let metadata: interfaces.ControllerMetadata = {path, middleware, target}; | ||
let metadata: interfaces.ControllerMetadata = { path, middleware, target }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I think this is your ide making an unexpected change?
src/decorators.ts
Outdated
@@ -39,7 +39,7 @@ export function Delete(path: string, ...middleware: interfaces.Middleware[]): in | |||
|
|||
export function Method(method: string, path: string, ...middleware: interfaces.Middleware[]): interfaces.HandlerDecorator { | |||
return function (target: any, key: string, value: any) { | |||
let metadata: interfaces.ControllerMethodMetadata = {path, middleware, method, target, key}; | |||
let metadata: interfaces.ControllerMethodMetadata = { path, middleware, method, target, key }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
src/constants.ts
Outdated
}; | ||
|
||
export enum ParameterType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be capitalized like the other constants?
Thanks! |
@Dirrk Thanks for pointing those things out. I noticed some other things that were
auto formatted as well. I was rushing because I had everything set up to
submit it and my kids got home and interrupted me. Should I resubmit the
pull request?
|
@AltekkeE just push more commits to the current branch. It will auto update this pr :) |
This reverts commit ee1b51c.
Changed ParameterType to PARAMETER_TYPE Formatting in README.md
@lholznagel - Done. I also notice that the code coverage report is not working correctly. It says 100% but no files are actually checked. This may be happening in the main inversify repo too. |
@@ -42,12 +42,17 @@ export class FooController implements interfaces.Controller { | |||
constructor( @inject('FooService') private fooService: FooService ) {} | |||
|
|||
@Get('/') | |||
private index(req: express.Request): string { | |||
private index(req: express.Request, res: express.Response, next: express.NextFunction): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn´t we just use @QueryParam('id') id: string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to show that you can still do it the original way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to show that you can still do it the original way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay.
Makes sense
LGTM 👍 |
👍 Amazing PR 💯 thanks a lot for this contribution. One question: did you find a way to fix the test coverage reports? |
@remojansen yesterday I checked travis and the problem is also in the main repo since some time. |
I think is probably some breaking change in one of the tools but is hard to find out which one :( |
I looked at it briefly but I didn't know if you were doing it for
transpired code or for typescript. It could have to do with not having
source maps enabled. I had found some other people that ran into a similar
problem but forget if it was recent. They solved it by making a new gulp
plugin for typescript to Istanbul
…On Sun, Apr 2, 2017 at 10:23 AM Remo H. Jansen ***@***.***> wrote:
I think is probably some breaking change in one of the tools but is hard
to find out which one :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKvP2NmKP9fPYCSEyWmJhfLovbrCP2N7ks5rr697gaJpZM4MwMrL>
.
|
Thanks a lot I will create an issue to track this down and see if we can fix it 👍 |
Just release |
Hi @AltekkeE I have noticed that in the docs you mention |
@remojansen I will take a look right now |
😬 Spelling mistake, Should be @RequestParam in the docs. It is correct down in the description part just not in that delete statement |
No worries.Would u like to send a PR? |
@remojansen [Gulp Problem] The problem is with gulp-mocha v4. I downgraded to ^3.0 and it works again. In a project that I am working on we are not using gulp. We just run the nyc using npm
the issue below points to this as well. |
* Fixed README.md @RequestParams to @RequestParam * After fixing the code coverage output I noticed that some lines were not covered Fixed @Cookies framework test to cover code in server.ts Removed unused code from decorators.ts
Add Decorators for binding method parameters to request parameters like in Spring or node-decorators
Description
@request - binds a method parameter to the request object - still provided at the end of the arguments list for backwards compatibility
@response - binds a method parameter to the response object - still provided at the end of the arguments list for backwards compatibility
@RequestParam - binds a method parameter to request.params or to a specific parameter if a name is passed
@QueryParam - binds a method parameter to request.query or to a specific query parameter if a name is passed
@RequestBody - binds a method parameter to request.body or to a specific body property if a name is passed
@RequestHeaders - binds a method parameter to the request headers
@Cookies - binds a method parameter to the request cookies
@Next - binds a method parameter to the next() function - still provided at the end of the arguments list for backwards compatibility
Related Issue
issue 521
inversify/InversifyJS#521
Motivation and Context
Better developer experience than using request and response
modeled after spring and node-decorators
some code reused from node-decorators
How Has This Been Tested?
unit tests for new code
original unit tests still pass
backwards compatible
node v7.4.0
Types of changes
Checklist: