1. feathers-socketio
The Feathers Socket.io real-time API provider
feathers-socketio
Package: feathers-socketio
Created by: feathersjs
Last modified: Sat, 18 Jun 2022 00:00:09 GMT
Version: 2.0.1
License: MIT
Downloads: 4,759
Repository: https://github.com/feathersjs/feathers-socketio

Install

npm install feathers-socketio
yarn add feathers-socketio

feathers-socketio

Important: For Feathers v3.0.0 or later use @feathersjs/socketio module instead of feathers-socketio.

Greenkeeper badge

Build Status
Code Climate
Test Coverage
Dependency Status
Download Status
Slack 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 https://docs.feathersjs.com/api/socketio.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));

License

Copyright (c) 2015

Licensed under the MIT license.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code