Giter VIP home page Giter VIP logo

Comments (9)

n1ru4l avatar n1ru4l commented on May 26, 2024 1

Koa supports generator function as a async await replacement.

from s3rver.

kherock avatar kherock commented on May 26, 2024 1

Promise.coroutine is essentially the main export of co which comes with Koa. I think we should be able to get by without involving Bluebird.

from s3rver.

n1ru4l avatar n1ru4l commented on May 26, 2024

Hey there!

First of all I love koa and async/await.
I also noticed that the code base is quite messy and not optimal.

We also should support all LTS node versions.
if we would do this could use koa 2 with generator functions (http://node.green/#ES2015-functions-generators). Once LTS for 6 is dropped we could easily change those to async functions.

I think a babel build step would be a bit of an overkill 🤔

What do you think @leontastic? I would definitely love to see this, however I do not have all the time to convert/rewrite the application.

from s3rver.

kherock avatar kherock commented on May 26, 2024

I'd be down to do most of it, I haven't been too strapped for time.

Node 4 supports most of the important ES2015 features (nvm spread and rest params are pretty useful, and its EOL is in April) including generators so I think it would be reasonable to target v6 and use either Koa 1 or Koa 2 with the deprecation warnings disabled.

from s3rver.

leontastic avatar leontastic commented on May 26, 2024

Code is very messy. I want to refactor it myself but I also haven't found the bandwidth to do so.

Not opposed to using Koa or Babel at all. I think introducing a build step is a worthy trade-off to allow us to take advantage of next-gen syntax features. As long as we keep the build config simple, so it doesn't introduce maintenance headaches down the road.

from s3rver.

kherock avatar kherock commented on May 26, 2024

Even if we go the Babel route, I recently realized that it isn't entirely feasible since a large portion of the Koa 2 ecosystem expects Node.js 7.6+, which means that we'd have to choose what dependencies we use carefully. We'd need to depend on versions written for Koa 1.x and we'd only be able to update once Node 6 exits LTS.

I think it's reasonable just to write for Koa 1 for now bearing in mind that it will need to be adapted for Koa 2 later. If you do it right it's pretty painless, I've done it for a much larger project than this when it got bumped up to Node 8.

from s3rver.

n1ru4l avatar n1ru4l commented on May 26, 2024

What parts of koa 2 couldn't we use? Also I think babel would be overkill.

from s3rver.

kherock avatar kherock commented on May 26, 2024

I just checked and it looks like most of the important ones are safe (koa, koa-compose, and koa-router) so we'd probably actually be fine. I also kind of agree that Babel is overkill since the only feature we actually need is async/await.

from s3rver.

leontastic avatar leontastic commented on May 26, 2024

Could just use Promise.coroutine from Bluebird to get async/await-like syntax without needing a babel transform. I'd love to introduce Bluebird anyway to convert async logic to promises.

from s3rver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.