Registry / database / fortune-ws

fortune-ws

JSON →
library1.0.4jsnpmunverified

WebSocket implementation for Fortune.js that provides real-time data synchronization using a MessagePack-based wire protocol. Current stable version is 1.0.4. The package has low release cadence (last release in 2019) and is primarily meant for Fortune.js users needing WebSocket support. Compared to generic WebSocket libraries, it integrates tightly with Fortune's data layer, offering server-side listener and automatic client syncing.

npm install fortune-ws
INSTALL
IMPORT
SIG · FORTUNE-WS
F
fortune-ws
databasejavascriptv1.0.4
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
const fortuneWS = require('fortune-ws')
import fortuneWS from 'fortune-ws'
Package is CJS-only; ESM import not supported.
fortuneWS.request
fortuneWS.request(client, options, state)
fortuneWS.request(options, client)
Arguments order: client first, then options and state.
fortuneWS.sync
fortuneWS.sync(client, instance)
fortuneWS.sync(instance, client)
First argument is the client instance, second is the Fortune instance.

Demonstrates creating a Fortune WebSocket server and client, including auto-syncing client.

const fortune = require('fortune') const fortuneWS = require('fortune-ws') // Create a Fortune instance (example) const store = fortune({ ... }) // Create WebSocket server const server = fortuneWS(store, (context, record, update) => { // change function - handle updates }, { port: 8080 }, (connection) => { console.log('New WebSocket connection') }) // Client request example fortuneWS.request({ host: 'localhost', port: 8080 }, { method: 'GET', path: '/users' }) .then(response => console.log(response)) .catch(err => console.error(err)) // Auto-syncing client const listener = fortuneWS.sync(clientStore, store) // Call listener.close() to stop syncing
Debug
Known issues
gotcha`fortuneWS.request` requires `client` object with `host` and `port`, not a WebSocket instance.
fix
Pass an object `{ host, port }` as first argument to `request`.
affects: >=1.0.0
gotchaThe `fortuneWS` default export is a function that returns a server (Node.js `http.Server`). It also has `request` and `sync` methods attached.
fix
Use `const fortuneWS = require('fortune-ws')` and then `fortuneWS(instance, ...)` for server.
affects: >=1.0.0
deprecatedPackage is in maintenance mode with no active development. Last release in 2019.
fix
Consider using alternative real-time data libraries or upgrade to a maintained fork.
affects: >=1.0.0
Errors
Common errors & fixes
fortuneWS is not a function
Using `new fortuneWS(...)` incorrectly.
fix
Do not use `new`; call `fortuneWS(instance, change, options, callback)` directly.
Cannot find module 'fortune-ws'
Package not installed or not required correctly.
fix
Run `npm install fortune-ws --save` and ensure `require('fortune-ws')` is used.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
fortunerequiredCore ORM required for server-side websocket integration
msgpack-literequiredUsed for message serialization over WebSocket
Agent activity
4 hits · last 30 days
node
4
Resources
fortune-ws — npm install fortune-ws · libregistry