Skip to content
The Feathers Socket.io real-time API provider
JavaScript
Find file
Latest commit 458a3d3 @daffl daffl 1.3.3

README.md

feathers-socketio

Build Status

The Feathers Socket.io real-time API provider

About

This provider exposes Feathers services through a Socket.io real-time API. It is compatible with Feathers 1.x and 2.x.

Note: For the full API documentation go to feathersjs.com/docs/providers.html.

Quick example

import feathers from 'feathers';
import socketio from 'feathers-socketio';

const app = feathers()
  .configure(socketio(function(io) {
    io.on('connection', function(socket) {
      socket.emit('news', { hello: 'world' });
      socket.on('my other event', function (data) {
        console.log(data);
      });
    });

    io.use(function(socket, next) {
      socket.feathers.data = 'Hello world';
      next();
    });

    io.use(function (socket, next) {
      // Authorize using the /users service
      app.service('users').find({
        username: socket.request.username,
        password: socket.request.password
      }, next);
    });
  }));

app.use('/todos', {
  get: function(id, params) {
    console.log(params.data); // -> 'Hello world'

    return Promise.resolve({
      id,
      description: `You have to do ${name}!`
    });
  }
});

Client use

import io from 'socket.io-client';
import feathers from 'feathers/client';
import socketio from 'feathers-socketio/client';

const socket = io('http://path/to/api');
const app = feathers()
  .configure(socketio(socket));

Changelog

1.2.0

1.1.0

  • Added Socket.io client and browser mapping for universal module usage

1.0.0

  • Initial release of extracted module from Feathers 1.3

License

Copyright (c) 2015

Licensed under the MIT license.

Something went wrong with that request. Please try again.