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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 no longer clobber koa context #879

Merged
merged 3 commits into from Aug 29, 2019
Merged

Conversation

marutypes
Copy link
Contributor

Fixes #876

Description

This PR fixes the issue we were having where our use of the spread operator on the ctx we got passed by Koa broke a bunch of the proxying / getters on that object, leading things to not work unexpectedly and require delving into ctx.request properties directly.

This PR is actually a breaking change, switching the API for render functions from (ctx: Koa.Context & {locale: string}) => JSX to (ctx: Koa.Context, data: {locale: string}).

@marutypes marutypes force-pushed the fix-clobbering-koa-context branch 2 times, most recently from 0c84938 to 004d8ce Compare August 20, 2019 18:22

expect(ctx.body).toContain(myCoolApp);
});

// we cannot test this with `createMockContext` because it actually clobbers the proxy methods itself :(
Copy link
Contributor

Choose a reason for hiding this comment

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

馃槀

Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue for this? Seems... problematic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the PR, I was just doing it wrong and am a dumdum

import App from '../app';

const app = createServer({
render: (ctx: RenderContext) => <App location={ctx.request.url} />
render: (ctx: Context) => <App location={ctx.request.url} />
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't ever need to specify the type explicitly here I don't think?


expect(ctx.body).toContain(myCoolApp);
});

// we cannot test this with `createMockContext` because it actually clobbers the proxy methods itself :(
Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue for this? Seems... problematic

@lemonmade
Copy link
Member

@michelleyschen can you take this one over?

@cartogram cartogram force-pushed the fix-clobbering-koa-context branch 8 times, most recently from 59de437 to c9de133 Compare August 29, 2019 14:13
@cartogram cartogram merged commit 6c0fe7b into master Aug 29, 2019
@cartogram cartogram deleted the fix-clobbering-koa-context branch August 29, 2019 17:01
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.

Koa request alias does not work
4 participants