CanhazDB is a lightweight, event-sourced database built on top of NATS JetStream. It provides a simple HTTP API for CRUD operations and uses an in-memory database with event sourcing for persistence.
- HTTPS server for secure communications
- CRUD operations (Create, Read, Update, Delete)
- Event sourcing using NATS JetStream
- In-memory database for fast read operations
- Configurable settings for different environments
- Node.js (version 14 or higher recommended)
- NATS server running with JetStream enabled
-
Clone the repository:
git clone https://github.com/canhazdb/server.git cd canhazdb -
Install dependencies:
npm install -
Set up your SSL certificates in the
certsfolder:cert.pem: Your SSL certificatekey.pem: Your SSL private key
Edit the configuration files in the src/config directory to match your environment:
development.ts: Configuration for development environment- Add more configuration files as needed for different environments
To start the server:
npm start
The server will start on the configured port (default is 3000 for development).
POST /:collection: Create a new documentGET /:collection/:id: Retrieve a documentGET /:collection: Retrieve all documents in a collectionPUT /:collection/:id: Update a documentPATCH /:collection/:id: Partially update a documentDELETE /:collection/:id: Delete a document
Run the tests using:
npm test
src/: Source codeconfig/: Configuration filescreateServer.ts: Main server creation logicindex.ts: Entry point
tests/: Test files
Contributions are welcome! Please feel free to submit a Pull Request.