This demo will walk you through the creation of a Node.js project powered by WebSockets and HarperDB. The application will be a data entry CLI with an additional display script.
- Ensure you have Node.js v14 and Docker Desktop installed.
- Create a new folder for the project and set it as the current working directory.
- Create a docker-compose.yml file with the provided configuration to set up HarperDB using Docker.
- Initialize a new npm project and install the required dependencies.
- Create three project files: init.js, data-entry.js, and data-display.js.
- Launch HarperDB using Docker with docker-compose up.
- init.js: Contains setup operations for the schema and table in HarperDB. It uses undici, a fast HTTP client, to perform the operations.
- data-entry.js: Allows data entry into the HarperDB table through a CLI. It uses HarperDBWebSocketClient to insert records over WebSockets.
- data-display.js: Subscribes to the HarperDB table and logs every new record inserted using WebSocket.