From ba0c6df3c127dc2eda9114228ebf9447b781086b Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 01:12:29 +0100 Subject: [PATCH] FeathersJS - Updates --- backend/feathers.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/feathers.js b/backend/feathers.js index 559b2f6..4cdbc08 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -159,7 +159,7 @@ channel.connections // contains a list of all connections in this channel channel.length // returns the total number of connections in this channel service.publish([event,] fn) // registers a publishing function for a specific service for a specific event or all events if no event name was given -app.publish([event,] fn) +app.publish([event,] fn) // registers an event publishing callback app.on('connection', connection => {}) // fired every time a new real-time connection is established app.on('login', (payload, info) => {}) // sent by the authentication module and also contains the connection in the info object that is passed as the second parameter @@ -182,6 +182,26 @@ npm install @feathersjs/socketio --save npm install @feathersjs/primus --save ``` +const feathers = require('@feathersjs/feathers'); +const express = require('@feathersjs/express'); + +// Create an app that is a Feathers AND Express application +const app = express(feathers()); + +// Register a service +app.use('/todos', { + get(id) { + return Promise.resolve({ id }); + } +}); + +// Register an Express middleware +app.use('/test', (req, res) => { + res.json({ + message: 'Hello world from Express middleware' + }); +}); + /* ******************************************************************************************* * 3. CLIENT: More details on how to use Feathers on the client.