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.

[Suggestion] Refactor NPM ports out to dedicated third party modules

See original GitHub issue

While working on my own toy Deno server project I noticed that several of the core NPM modules that make up various Node HTTP stacks (from https://github.com/pillarsjs and https://github.com/jshttp) have since been converted to their third party modules (by basically two people!!).

I don’t know if the desire is maintain ports and tests of these modules in this project as a sort of monorepo, or whether there is appetite to keep the focus of Oak lean and use dedicated third parties for non “core” smarts?

Some of the modules in question that look like the easiest swap / best fit are:

(They have done several others for content negotiation, Vary headers etc. but aren’t necessarily the best fit, or at least stray from how Oak have attacked those areas or aren’t yet implemented in Oak.)

Happy to implement refactors for the two mentioned above if this matches the strategy. 😄

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kitsonkcommented, May 29, 2020

Personal opinion, the Node.js ecosystem is littered with single module repos and things have been broken up too much. Those modules that are related to providing an HTTP server I would like to keep in oak and try to keep dependencies down to just std.

So far there are two exceptions to that, media_types, which is maintained here as a seperate repo only because it was moved to std to only have it be “ejected” and needing to take over again. The other is pillarjs/path-to-regexp because it is pretty specific and complex and it is written in TypeScript with no platform specific logic. That is the advantage of the Deno eco-system, in that we can use that discreet bit of logic without any other overhead than expressing that dependency.

Both http_errors and encodeurl are unlikely to ever change in their functionality, so I don’t think maintenance is really an issue. Some could argue why doesn’t ako use the oak modules, as they existed in oak prior to ako and they don’t have to be in a seperate repo to be able to pick and choose using them.

Would be glad to have a chat with @ngot and @wileam about ako and why they felt oak didn’t meet their needs, especially because they are in the same time zone as myself.

1reaction
ngotcommented, May 30, 2020

Thanks @asos-craigmorten for recommending my ported modules to oak, I really appreciate that. Kudos to @kitsonk for creating oak for Deno developers.

Regarding the questions, let me try to answer,

why they felt oak didn’t meet their needs

That is not the problem of oak, it is mine. When I started to explore Deno, I didn’t find any Koa like framework(Forgive me, I didn’t find oak at the beginning). So, I decided to write a Koa like framework for Deno. I shared that idea on Discord, people told me there was already oak there. I quickly went through oak source code, and find some interesting points:

  • It is not going to following koa’s API design
  • It is not fully functional compatible with Koa

I understand the reason behind the decision, not all of Koa’s pattern are suitable for Deno. Redesign and make it looks more native to Deno and TS is needed to build a new community.

So, I changed my mind to stop doing duplicated work, but only PORT a Koa compatible framework to Deno instead, even though many designs of Koa might not be the best practice in Deno, and I also want to retain the dark magic of Koa. There are several reasons:

  • I personally want a full-feature Koa like framework to migrate my personal project into Deno.
  • I believe a PORTed Koa, will bring more people from the Node community to try Deno.
  • Even there are many downsides in Koa, but it already proved itself in many production-level projects, if I can port it and migrate a project from Node to Deno, it will give people more confidence to adopt Deno.

single module repos and things have been broken up too

I agree with this. Node modules hell is a nightmare. But I still did that somehow.

Why?

IMO, writing, or maintain a module is different from adopting a module. A high-quality module should be well documented, a good history log, and easy to find. I separate them into dedicated repos is mostly due to the SEO consideration.

But, from an adopter perspective, But what if the host of the URL goes down? The source won’t be available. gives a great guide. Maybe, I should link that page to the document of the ported modules.

Those modules are already in oak, there is no need to link to a third-party module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

requires-port - npm
The module exports it self as function and requires 2 arguments: The port number, can be a string or number. Protocol, can be...
Read more >
Why the Hell Would I Use Node.js? A Case-by-case Tutorial
Node.js can solve I/O scaling, but was not created to compute scaling problems. Learn why and when to use Node.js in this case-by-case...
Read more >
7 ways to improve Node.js performance at scale
Learn about data handling methods you can use to enhance Node.js performance, how to manage more connections with load balancing, and more.
Read more >
How to Debug a Node.js Application: Tips, Tricks and Tools
Craig Buckler presents a series of tips, tricks, techniques and tools for debugging a Node.js application.
Read more >
Modern IDEs are magic. Why are so many coders still using ...
We love what we grew up with, be it Star Trek jokes, Vim, or Emacs. ... themes and integrates with HTML, JavaScript, CSS,...
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