Registry / communication / serve-socket

serve-socket

JSON →
library6.0.2jsnpmunverified

A real-time WebSocket service for restaurant waiter coordination, built for Angular 15+ with TypeScript types included. Version 6.0.2 is stable and actively maintained. Integrates with MQTT 5+ for message brokering. Key differentiators: Angular-native dependency injection, automatic reconnection, and order lifecycle events.

npm install serve-socket
INSTALL
IMPORT
SIG · SERVE-SOCKET
S
serve-socket
communicationjavascriptv6.0.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.

ServeSocketService
import { ServeSocketService } from 'serve-socket';
const { ServeSocketService } = require('serve-socket');
Library is ESM-only and ships TypeScript declarations.
WaiterEvent
import { WaiterEvent } from 'serve-socket';
import { WaiterEvent } from 'serve-socket/models';
All types are exported from the main entry point.
OrderStatus
import { OrderStatus } from 'serve-socket';
import { OrderStatus } from 'serve-socket/enums';
Enum is re-exported from the root module.
ServeSocketModule
import { ServeSocketModule } from 'serve-socket';
import { ServeSocketModule } from 'serve-socket/serve-socket.module';
Import the module directly from the package root for Angular usage.

Demonstrates importing ServeSocketModule, configuring the MQTT broker, and using the service to emit and listen for WebSocket events.

import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { ServeSocketModule } from 'serve-socket'; import { AppComponent } from './app.component'; @NgModule({ declarations: [AppComponent], imports: [ BrowserModule, ServeSocketModule.forRoot({ brokerUrl: process.env['MQTT_BROKER'] ?? 'ws://localhost:9001' }) ], bootstrap: [AppComponent] }) export class AppModule {} import { Component, OnInit } from '@angular/core'; import { ServeSocketService, WaiterEvent } from 'serve-socket'; @Component({ selector: 'app-waiter', template: '<button (click)="callWaiter()">Call Waiter</button>' }) export class WaiterComponent implements OnInit { constructor(private serveSocket: ServeSocketService) {} ngOnInit() { this.serveSocket.on('order-ready', (event: WaiterEvent) => { console.log('Order ready:', event.tableId); }); } callWaiter() { this.serveSocket.emit('call-waiter', { tableId: 5 }); } }
Debug
Known issues
breakingDrop support for Angular <15: The library now requires @angular/core >=15.
fix
Upgrade your project to Angular 15 or higher.
affects: >=6.0.0
breakingMQTT version bump: peer dependency changed from mqtt@4.x to mqtt@5.x.
fix
Update mqtt in your package.json to >=5.0.0.
affects: >=6.0.0
deprecatedThe 'ServerSocketService.emitLocationUpdate' method is deprecated in favor of 'emitTableUpdate'
fix
Replace calls to emitLocationUpdate with emitTableUpdate.
affects: >=6.0.0
gotchaModule must be imported with forRoot() when used in the root NgModule; using forChild() incorrectly may cause double service instantiation.
fix
Use ServeSocketModule.forRoot() in AppModule imports only.
affects: *
Errors
Common errors & fixes
Error: Can't resolve 'mqtt'
Missing mqtt peer dependency
fix
npm install mqtt@>=5.0.0
NullInjectorError: No provider for ServeSocketService!
ServeSocketModule not imported or not configured via forRoot()
fix
Add ServeSocketModule.forRoot(...) to your root NgModule imports.
Property 'emitCallWaiter' does not exist on type 'ServeSocketService'
API changed; method renamed in v6
fix
Use emit('call-waiter', ...) instead of emitCallWaiter.
Upgrade
Version history
6.0.2latest on npm
Audit
Dependencies
@angular/commonrequiredProvides Angular HTTP client and common services
@angular/corerequiredRequired for Angular dependency injection and lifecycle
mqttrequiredUsed for MQTT protocol communication with the broker
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
serve-socket — npm install serve-socket · libregistry