How vorandrew/deribit-ws-nodejs works
Project type and purpose
• This is an open-source Node.js library that provides a generic wrapper around Deribit.com’s WebSocket API.
• Its purpose is to simplify connecting, authenticating, subscribing to events, sending actions, and handling messages from the Deribit exchange in a standard way.
File structure
• Top-level files:
• package.json, README.md, .gitignore, .npmignore, .prettierignore – standard Node package config and docs.
• src/index.js – the library entry point and public API.
• src/adapter.js – likely contains the logic to convert raw WebSocket events into consumable events or to format outgoing requests.
• No “frontend” or “backend” directories; this is a pure-library component.
• No microservices or MVC patterns; instead, a small, single-process event-driven design.
README for additional insights
• The README shows:
• How to construct the client with credentials and callbacks.
• Lifecycle: connect, await ws.connected, perform actions, hook events, disconnect.
• Under the hood it uses a WebSocket to Deribit, JSON-RPC style “action” calls, and event hooks.
Detailed capture of essential elements
• Break the library into at least these components:
1. Entry Point / Public API
2. Configuration & Authentication Handler
3. Connection Manager (WebSocket life cycle)
4. Adapter (message normalization)
5. Hook Manager / Event Emitter
• Promise/future (ws.connected) as part of the connection flow.
• Error path: Connection Manager → Error Callback