Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Support Koa 2.0 #47

Merged
merged 12 commits into from
May 10, 2018
Merged

Support Koa 2.0 #47

merged 12 commits into from
May 10, 2018

Conversation

doug-wade
Copy link
Collaborator

lib/index.js Outdated
pretty: false,
compileDebug: false,
locals: {},
basedir: `${__dirname}/templates`,
Copy link
Collaborator Author

@doug-wade doug-wade Sep 6, 2017

Choose a reason for hiding this comment

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

note that this means that client templates are not resolvable currently -- we'll need to fix this before we merge.

@nickserv
Copy link
Member

nickserv commented Sep 6, 2017

Wow, nice work, thanks! I'll try to do a detailed review tonight or tomorrow.

@nickserv nickserv self-requested a review September 6, 2017 01:09
@@ -3,3 +3,4 @@ node_modules
coverage
cache
*.log
*.out
Copy link
Member

Choose a reason for hiding this comment

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

What generates these files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do -- when I'm debugging, I pipe output to out files, like npm test | tee test.out

README.md Outdated
@@ -12,14 +12,6 @@ A suite of Koa utilities allowing for quicker bootstrapping,
as well as a consequential guide on how to write apps using the Koa philosophy.
Think of it as a KrakenJS for Koa.

## Status

Beware! Koala is alpha software!
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 it would help to leave the alpha warning, unless you'd like this to go into a stable release before we publish another unstable release.

README.md Outdated
Beware! Koala is alpha software!

[Koa 2](https://github.com/koajs/koala/issues/17) is currently
unsupported. Please refer to [Contributing](CONTRIBUTING.md) if you'd like to
Copy link
Member

Choose a reason for hiding this comment

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

Let's also remove this from contributing, unless if we have other Koa 2 related issues after merging this pull request.

Copy link
Member

Choose a reason for hiding this comment

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

Done.


module.exports = function (app, options) {
options = options || {};

// methods
if (options.responseTime !== false) app.use(require('koa-response-time')());
app.use(require('./trace'));
// app.use(require('./trace'));
Copy link
Member

Choose a reason for hiding this comment

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

Did you want to use koa-trace for this? I noticed you have a fork of it.

package.json Outdated
"supertest": "^2.0.0"
"istanbul-harmony": "0",
"mocha": "^3.5.0",
"supertest": "^3.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Sweet, thanks for fixing the supertest update. I also like that we're using more ^ versions here.

package.json Outdated
"istanbul": "^0.4.5",
"mocha": "3",
"supertest": "^2.0.0"
"istanbul-harmony": "0",
Copy link
Member

Choose a reason for hiding this comment

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

istanbul-harmony was deprecated in favor of istanbul@>=0.4.0. Let's revert the first line of devDependencies please.

Copy link
Member

@nickserv nickserv Sep 6, 2017

Choose a reason for hiding this comment

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

Whoops, I didn't realize the new syntax is broken on that version of Istanbul. I would like to eventually switch to their new CLI, https://github.com/istanbuljs/nyc, which I believe solves this problem. Either way I noticed this is fixed on instanbul@v1.1.0-alpha.1 but I feel weird about using an alpha dependency. We can leave this as is for the sake of this pull request though.

@nickserv
Copy link
Member

nickserv commented Sep 6, 2017

I pushed some minor fixes here. I also made an additional pull request based against this one so you could review the change separately, it converts Koala to a class to match Koa 2's usage doug-wade#1.

I'm having a hard time fixing the 404/500 errors in the test failures, can you take a look when you have a chance? We should also drop this in middleware functions and consider not checking the test value of NODE_ENV (see https://github.com/koajs/koa/blob/master/docs/migration.md).

lib/index.js Outdated
this.use(etag());
this.use(bodyParser());
// this.use(convert(trace));
const pug = new Pug({
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will prefer passing a merged options.pug object to pug, something like new Pug(options.pug) with required defaults.
So that it can be configured by someone who is using this.

var etag = require('koa-etag')(options);

return function* conditionalGet(next) {
return async function (next) {
yield* etag.call(this, next);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why yield, why not await ?

@@ -2,7 +2,7 @@
describe('Body Parsing', function () {
describe('.request.json()', function () {
it('should parse a json body', function (done) {
var app = koala()
var app = new Koala()
app.use(function* () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Guess we can also move generators here to async/await ?

@doug-wade doug-wade changed the title WIP: Support Koa 2.0 Support Koa 2.0 Apr 29, 2018
@doug-wade
Copy link
Collaborator Author

yo @nickmccurdy @bhaskarmelkani, I think this one's ready to merge. I'd appreciate a once-over if you've got a sec.

@bhaskarmelkani
Copy link
Collaborator

Hey,

Thanks for the updates. I completely missed the notification for your message.

Looks good to me :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants