or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdindex.mdmiddleware.md
tile.json

tessl/npm-feathersjs--socketio

The Feathers Socket.io real-time API provider for bidirectional communication between clients and servers

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@feathersjs/socketio@5.0.x

To install, run

npx @tessl/cli install tessl/npm-feathersjs--socketio@5.0.0

index.mddocs/

Feathers Socket.io

The Feathers Socket.io real-time API provider enables bidirectional communication between clients and servers through WebSocket connections. It integrates Socket.io with Feathers' service architecture, allowing real-time method calls, event subscriptions, and automatic connection management.

Package Information

  • Package Name: @feathersjs/socketio
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @feathersjs/socketio

Core Imports

// Main configuration function (CommonJS style export)
import socketio = require("@feathersjs/socketio");

// Types and interfaces (when needed for advanced usage)
import type { FeathersSocket, ParamsGetter, NextFunction } from "@feathersjs/socketio/middleware";

For CommonJS:

const socketio = require("@feathersjs/socketio");

Basic Usage

import { feathers } from "@feathersjs/feathers";
import socketio = require("@feathersjs/socketio");

const app = feathers();

// Basic configuration
app.configure(socketio());

// With custom port and options
app.configure(socketio(3030, { 
  cors: { origin: "*" } 
}));

// With configuration callback
app.configure(socketio((io) => {
  io.sockets.setMaxListeners(64);
}));

await app.listen(3030);

Architecture

The package is built around key components:

  • Configuration Function: The main configureSocketio function that integrates Socket.io with Feathers
  • Middleware System: Built-in middleware for connection handling, parameter extraction, and authentication
  • Application Extension: Extends Feathers Application with Socket.io-specific properties and methods
  • Real-time Integration: Maps Socket.io connections to Feathers' real-time connection system

Capabilities

Socket.io Configuration

Main configuration function for integrating Socket.io with Feathers applications, supporting various configuration patterns.

function configureSocketio(callback?: (io: Server) => void): (app: Application) => void;
function configureSocketio(
  options: number | Partial<ServerOptions>,
  callback?: (io: Server) => void
): (app: Application) => void;
function configureSocketio(
  port: number,
  options?: Partial<ServerOptions>,
  callback?: (io: Server) => void
): (app: Application) => void;

Socket.io Configuration

Middleware Types and Interfaces

The package exposes types and interfaces for advanced usage scenarios, particularly when working with custom Socket.io middleware.

interface FeathersSocket extends Socket {
  feathers?: Params & { [key: string]: any };
}

type ParamsGetter = (socket: Socket) => any;
type NextFunction = (err?: any) => void;

Internal Middleware Functions: The package automatically configures internal middleware for connection handling, authentication, and parameter extraction. While these functions are not directly accessible, their types are available for advanced customization scenarios.

Middleware Details

Additional Types

// Socket.io types from the socket.io package
interface Server { /* Socket.io Server interface */ }
interface ServerOptions { /* Socket.io ServerOptions interface */ }
interface Socket { /* Socket.io Socket interface */ }

// Feathers types
interface Application { /* Feathers Application interface */ }
interface Params { /* Feathers Params interface */ }
interface RealTimeConnection { /* Feathers RealTimeConnection interface */ }

Application Extension

The package extends the Feathers Application interface:

interface Application<Services, Settings> {
  io: any;
  listen(options: any): Promise<http.Server>;
}