Registry / messaging / alp-websocket

alp-websocket

JSON →
library6.1.2jsnpmunverified

WebSocket integration for the ALP framework, wrapping socket.io. Current stable version is 6.1.2, released under the ALP monorepo. Provides server-side Koa middleware and browser-side Ibex integration with configuration via YAML. Differentiator: tightly scoped to ALP ecosystem, relies on socket.io for transport. Minimal API surface; requires ALP-specific configuration pattern. Not intended for standalone use outside ALP projects.

npm install alp-websocket
INSTALL
IMPORT
SIG · ALP-WEBSOCKET
A
alp-websocket
messagingjavascriptv6.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (websocket function)
import websocket from 'alp-websocket'
const websocket = require('alp-websocket')
ESM-only package since v6
Server-side usage
const io = websocket(app)
const io = new websocket(app)
Function returns socket.io server instance, not constructor
TypeScript type import
import type { Server as SocketIOServer } from 'socket.io'
import { SocketIOServer } from 'alp-websocket'
Types are re-exported from socket.io, not directly exposed

Shows server-side setup: create Koa app, apply config, attach WebSocket via websocket(), and handle a connection event.

import Koa from 'koa'; import config from 'alp-node-config'; import websocket from 'alp-websocket'; const app = new Koa(); config(`${__dirname}/config`, { packageConfig })(app); const io = websocket(app); io.on('connection', (socket) => { console.log('a user connected'); socket.on('message', (data) => { console.log('received:', data); }); }); app.listen(3000);
Debug
Known issues
breakingESM-only package; CommonJS require() will fail
fix
Use import instead of require, or downgrade to 5.x if CJS required
affects: >=6.0.0
breakingRemoved default export returning socket.io constructor; now returns socket.io server instance directly
fix
Do not use 'new' when calling websocket(app); it's synchronous
affects: >=6.0.0
deprecatedNode.js <10.13.0 no longer supported
fix
Upgrade Node to >=10.13.0
affects: >=6.0.0
gotchaRequires ALP configuration object to be passed; websocket config key must exist in YAML
fix
Ensure config/common.yaml has websocket section with secure and port
affects: *
Errors
Common errors & fixes
TypeError: websocket is not a function
Using require() in ESM-only package or incorrect import
fix
Use import websocket from 'alp-websocket' (ESM) or check package version
Error: Cannot find module 'alp-websocket'
Package not installed or wrong version
fix
npm install alp-websocket@6.1.2
TypeError: io.on is not a function
websocket(app) was called with 'new' or not called at all
fix
Use const io = websocket(app) (no 'new')
ConfigError: Missing config for websocket
config file does not include websocket section
fix
Add websocket: { secure: true, port: 3001 } to common config
Upgrade
Version history
6.1.2latest on npm
Audit
Dependencies
socket.iorequiredcore WebSocket server implementation
Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
alp-websocket — npm install alp-websocket · libregistry