-
-
Notifications
You must be signed in to change notification settings - Fork 797
Closed
Milestone
Description
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()):
const feathers = require('feathers');
const express = require('feathers-express');
const app = feathers()
// Make this app Express compatible
.configure(express())
// Configure REST API that uses Express
.configure(express.rest());
// Use any Express middleware
app.use(bodyParser.json());
// Use Feathers services normally
app.use('/todos', {
get(id) {
return Promise.resolve({ id, description: `You have to do ${id}!` });
}
});Koa
Koa support came up several times (see #83 and #58). This can now be done very similar:
const feathers = require('feathers');
const koa = require('feathers-koa');
const app = feathers()
// Make this app Koa compatible
.configure(koa())
// Configure Koa REST handler
.configure(koa.rest());
// Use normal Koa middleware
app.use(function *(){
this.body = 'Hello World';
});
// Use a Feathers service through app.service
app.service('/todos', {
get(id) {
return Promise.resolve({ id, description: `You have to do ${id}!` });
}
});Reactions are currently unavailable