Skip to content
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

feat: directly calling response #286

Merged
merged 4 commits into from
Sep 23, 2017
Merged

feat: directly calling response #286

merged 4 commits into from
Sep 23, 2017

Conversation

fabiob
Copy link
Contributor

@fabiob fabiob commented Sep 8, 2017

I've added some tests for the documented way to write to the response directly, as in: https://github.com/pleerock/routing-controllers#using-request-and-response-objects. It looks like #241 broke this usage pattern.

@fabiob
Copy link
Contributor Author

fabiob commented Sep 8, 2017

I've included a proposal to detect whether the user code handled the response manually or not.

@fabiob
Copy link
Contributor Author

fabiob commented Sep 8, 2017

P.S.: the failing tests are newly detected failures from the assertRequest change I've made.

@fabiob fabiob changed the title Directly calling response Directly calling response + GET/HEAD fix Sep 8, 2017
@@ -209,6 +209,12 @@ export class KoaDriver extends BaseDriver implements Driver {
*/
handleSuccess(result: any, action: ActionMetadata, options: Action): void {

// if the action returned the context or the response object itself, short-circuits
if (result && (result === options.response || result === options.context)) {
options.next();
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to return next call in koa, otherwise you will break the chain. We don't have every edge case covered in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed it.

@MichalLytek MichalLytek added type: fix Issues describing a broken feature. community labels Sep 9, 2017
Copy link
Contributor

@MichalLytek MichalLytek left a comment

Choose a reason for hiding this comment

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

Looks good but the test-utils.ts part needs to be reviewed by @pleerock.

@NoNameProvided
Copy link
Member

@19majkel94 we can merge right? or do we want to wait for a review from @pleerock ?

@MichalLytek
Copy link
Contributor

I would wait for @pleerock review due to changes in test utils.

@fabiob
Copy link
Contributor Author

fabiob commented Sep 17, 2017

Rebased to include latest master.

@fabiob
Copy link
Contributor Author

fabiob commented Sep 23, 2017

Would it help if I extract the test utils into another PR?

@fabiob fabiob changed the title Directly calling response + GET/HEAD fix Directly calling response Sep 23, 2017
@fabiob
Copy link
Contributor Author

fabiob commented Sep 23, 2017

OK, I've extracted the test-utils change into another PR (#297).

@NoNameProvided @19majkel94, do you guys think we can merge this faster?

@MichalLytek
Copy link
Contributor

@NoNameProvided @19majkel94, do you guys think we can merge this faster?

Yes, but we still have to wait for @pleerock to release the merged PRs on npm 😜

@MichalLytek MichalLytek removed the request for review from pleerock September 23, 2017 20:32
@MichalLytek MichalLytek merged commit 2ab4f34 into typestack:master Sep 23, 2017
@fabiob fabiob deleted the directly-calling-response branch March 27, 2019 03:02
@NoNameProvided NoNameProvided changed the title Directly calling response feat: directly calling response Aug 9, 2020
@typestack typestack locked as resolved and limited conversation to collaborators Aug 9, 2020
@NoNameProvided
Copy link
Member

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: fix Issues describing a broken feature.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants