question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do you have any plans for supporting koa@2 and make using more convenient?

See original GitHub issue

Hi.

Trie-router is the official router and I think we could give second breath to it.

Proposal \ my vision

Requirements

  1. It should works with node 7.x.x and higher
  2. It should support only koa@2 and higher
  3. It should be mountable
  4. It should be powerful as it is now

API

  • Instantiation should requires new operator (like Koa@2)

    let router = new Router();
    
  • Routers could be define like

    router[use|get|post|put|del|patch]([path], [...middleware]);
    
    • where path & middleware both optional but it requires at least one of them
    • path is {String|{Array<String>}
    • middleware is {Function|AsyncFunction|Array<[Function|AsyncFunction]>}
  • Router should implements router.middleware() like koa.middleware() for mounting (composing)

  • ctx.params like https://github.com/koajs/trie-router/tree/1.1.0#thisparams

  • https://github.com/koajs/trie-router/tree/1.1.0#features

What do you think about it?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathanongcommented, Feb 23, 2017

thanks for your work. your changes sound good. you can publish, but I would hold off with tagging the koa@2 version as latest until I (or someone else) publishes koa@2 this weekend.

let me know if u you need npm rights

Read more comments on GitHub >

github_iconTop Results From Across the Web

Awesome Koa.js Web Framework - GitHub
You can find the Testfiles on travis-deadlink-scanner. Links. Koa - Expressive middleware for node.js using generators; co - The ultimate generator based flow- ......
Read more >
Building A Server-Side Application With Async Functions and ...
In this article, I would like to show you a very practical example of building a server-side application using Koa 2, a new...
Read more >
How To Build a "Hello World" Application with Koa
In this article, you will learn more about the Koa framework and build an app to get familiar with its functionality and philosophy....
Read more >
Is Express the Best Option? - Medium
Many beginners are more comfortable using Express because it is unopinionated or less abstracted from Node, meaning it is more similar to ...
Read more >
How to create Koa2 middleware which will modify response ...
body.toUpperCase(); }) // template rendering app.use(async function (ctx, next) { ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found