1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-18 00:24:07 +00:00

FeathersJS - Updates

This commit is contained in:
Julien Le Coupanec 2018-02-10 01:12:29 +01:00
parent 70a3fa3ebd
commit ba0c6df3c1

View File

@ -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.