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

Create v2 Migration document #920

Closed
wants to merge 12 commits into from

Conversation

JeffRMoore
Copy link
Contributor

Give v2 migration its own document.

Hopefully, this creates a place that can collect any other necessary documentation on migrating. I've added some of the comments from #533, which is hard to find now because the issue is closed. Slight updates to main readme to make it friendlier to those new to Koa with v2.

@codecov
Copy link

codecov bot commented Feb 27, 2017

Codecov Report

Merging #920 into master will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff          @@
##           master   #920   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      4           
  Lines         425    425           
  Branches      101    101           
=====================================
  Hits          425    425
Impacted Files Coverage Δ
lib/application.js 100% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 188c096...1ea3068. Read the comment docs.

Readme.md Outdated
@@ -91,35 +91,13 @@ app.use(co.wrap(function *(ctx, next) {
}));
```

### Old signature middleware (v1.x) - Deprecated
### KOA v1.x Middleware Signature
Copy link
Member

Choose a reason for hiding this comment

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

We never use all caps. can we change this to Koa? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Fixed.

@@ -80,7 +80,7 @@ app.use((ctx, next) => {

### GeneratorFunction

To use generator functions, you must use a wrapper such as [co](https://github.com/tj/co) that is no longer supplied with Koa.
To use generator functions, you must use a wrapper such as [co](https://github.com/tj/co).
Copy link
Member

@jonathanong jonathanong Feb 27, 2017

Choose a reason for hiding this comment

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

i think we should just remove this section as it would only confuse people

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was weak, but didn't know if the unbundling of co mattered. Seems not. Removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, wait! I completely misread this. My mistake. I thought you were referring to the dependency section in the migration page which is where I moved the "no longer supplied text" to.

@jonathanong When you refer to "this section" are you referring to the "GeneratorFunction" section?

Should I add back the dependency section I just removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking about it, I agree. The overview document should focus on the recommended way, which I think now is async and leave the other two formats for deeper documentation. I'd like to submit that as a separate PR, though, so as to not block the merging of this migration guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and restored the Dependency changes section I mistakenly removed. I don't know if its meaningful, I'm not actually a v1.x user, I was attracted by the v2.x release.

Copy link
Member

Choose a reason for hiding this comment

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

yup, I meant the GeneratorFunction section. we shouldn't be recommending people to use generator functions, and if they do, it should be the v1.x version that should be migrated to async functions. this is a generation function with (ctx, next) arguments, which is a mix of v1.x and v2.x APIs and is awkward

@jonathanong
Copy link
Member

this is great! anyone else have recommendations?


## v1.x support

The v1.x branch is still supported and may also receive feature updates. Except for this migration
Copy link
Contributor

@fl0w fl0w Feb 28, 2017

Choose a reason for hiding this comment

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

may also receive feature updates

Is this misleading? I think I saw @jonathanong expressing no intent to add features in v1.x branch from this point on. Just to make sure.

Copy link
Member

Choose a reason for hiding this comment

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

i would say, "should not expect feature updates".

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 to "should not expect feature updates."

@jonathanong jonathanong self-assigned this Mar 1, 2017

## Upgrading middleware

You will have to convert your generators to async functions with the new middleware signature:
Copy link
Member

Choose a reason for hiding this comment

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

i would show next() in the signature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Fixed.


1. Wrap all your current middleware in koa-convert
2. Test
3. npm outdated to see which koa middleware is outdated
Copy link
Member

Choose a reason for hiding this comment

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

wrap commands in backticks so they're easier to read npm outdated

1. Wrap all your current middleware in koa-convert
2. Test
3. npm outdated to see which koa middleware is outdated
4. Update one outdated middleware, remove using koa-convert
Copy link
Member

Choose a reason for hiding this comment

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

same with modules koa-convert

@jonathanong
Copy link
Member

except for small fixes 👍

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