-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Make Feathers server framework independent to work with Express, Koa and Hapi #258
Comments
The biggest barrier to this I think will be authentication, specifically how we get access to the request and response object and how the passport middleware works with Koa, etc. At a quick glance it doesn't look too bad with Koa. We'd just need to use https://github.com/rkusa/koa-passport-example and IMHO, if we are looking to be more flexible and not tied to a framework we're probably better just using standalone modules for routing, content negotiation, etc. |
For socket support with Koa we use this for inspiration: https://github.com/koajs/koa.io. |
|
@ahdinosaur ya that looks like more the right way to go IMHO. |
I think we should make Feathers a library instead of a framework - that would make it more independent on the transport as well. Examples: Common codeconst feathersApp = feathers().configure(rest());
feathersApp.service('todos', new NeDB('todos'));
export default feathersApp; Framework-specificKoa import feathersApp from './feathersApp';
import Koa from 'koa';
import adapter from 'feathers-koa';
const app = new Koa();
app.use(adapter(feathersApp)); Express import feathersApp from './feathersApp';
import express from 'express';
import adapter from 'feathers-express';
const app = express();
app.use(adapter(feathersApp)); Basically, the adapters will create the middleware for their particular framework. |
@daffl I just checked spirit and it looks very neat. It would be amazing to decouple feathers from express. With the up rise of so many new implementations different from express it would make feathers more robust in the future. Any decisions on this? |
This Authentication PR feathersjs-ecosystem/authentication#336 should be the only major piece we need in order to be able to support to different frameworks underneath. |
I've been giving this a lot more thought over the last few days and now that we are getting close to winding up Auk this is going to be the major goal for the Buzzard release. As nice as it is to be modular looking at usage numbers Express isn't going anywhere. It has 70 million downloads this last year, Koa is right up there with 1.4 million and Hapi with ~2.4 million. I think these numbers can be artificially inflated by build systems, deploy frequency, size of deployments, etc. but this gives a general idea of how popular things are. Being completely honest, looking at the numbers there really isn't a lot of incentive to support anything but express. The major reasons I see would be:
In my mind the first "engine" to support other than Express would be Koa. It's the most similar in design to Express and provides nice support for future ES6/ES7 language functions. It also seems to be our most requested. Personally I'd rather have support for raw node libs but that might be a lot of work. What needs to happen
There might be more things. @daffl would have a better idea, specifically around socket/rest setup. Other Considerations
|
Agreed! This way, people can learn Feathers once and deploy on any server that has an adapter. Great idea! |
The challenge lies in converting libraries that rely on connection-specific things like headers. About the popularity contest, my primary reason for wanting to use Koa is not because it's popular (not as much as express), but because it's more stable in terms of handling middleware errors. |
Please let's move Feathers to an architecture more suitable to a thin API gateway (classic web server) and stupid/simple web services that can be deployed stand-alone and are protocol independant, just listening to messages of interest (ie. best practice Micro Service pattern). Then we can start to integrate smoothly with Seneca and other popular Node.js Micro Services frameworks. And yes, FeathersJS should be agnostic to Express, Koa, Hapi, whatever... Happy days! |
Have you guys seen this https://github.com/fastify/fastify? I'd love to use it with FeathersJS, what's the status of this issue? |
@andreafalzetti still moving forward. You can see some progress going on here: feathersjs-ecosystem/express#3 |
Yeah, would be super sweet to integrate feathers with fastify! Let's do it :) |
The basic integration should be fairly straightforward, however, it's authentication (specifically passport and oAuth) where things get hairy. Our plan was to remove the hard dependency on Express and after v3 investigate what integrations make sense. I saw a talk on Fastify last week and while it was interesting, it might make even more sense for Feathers to just use Nodes HTTP (and HTTP2!) with the router Fastify is using as the main integration. |
FYI, I started work on feathers-koa REST integration in feathers-rest-koa I think it would make sense to extract the REST client into a separate module/package and repo ;) |
The clients already are at https://github.com/feathersjs/feathers-rest-client also related: feathersjs-ecosystem/express#3 by @christopherjbaker |
As a newbie to Feathers: By 2018 is Feathers completely independent from Express? EDIT: Or in other words: Which other frameworks are supported. Is KOA fully supported? Thanks! Love the framework and thanks for the hard work! |
Ask @daffl, he's been working on it... Not sure about the current state of affairs though. |
Feathers is framework independent (as in you can e.g. only use it with @feathersjs/socketio or as a standalone client to talk to other services) but it only has HTTP API bindings for Express (in @feathersjs/express). Since the whole point of Feathers is abstracting the protocol specific things, the HTTP framework it is using ultimately shouldn't really matter that much and abstracting things like authentication away from Express is a pretty big task (all of Passport is built for Express and even the current Koa integrations just hack around that fact by mucking around with its request object to make it look like Express). Highest priority for new framework bindings for me would be plain Node HTTP which with a new service lookup mechanism would yield similar performance to Fastify and make websocket connections even faster. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
Now that Feathers works library independent on the client already (see #193), we don't really need Express as hard dependency for the server anymore either. Instead, we can create separate modules for Express, Koa and potentially Hapi that can be configured just like any other plugin:
Express
The only thing to change upgrading from a Feathers 2 application would be to
app.configure(express())
:Koa
Koa support came up several times (see #83 and #58). This can now be done very similar:
The text was updated successfully, but these errors were encountered: