moltendb-server-test
March 20, 2026 · View on GitHub
moltendb-server-test
Integration test suite for the MoltenDB HTTP server and WebSocket endpoint
Tests the @moltendb-web/query TypeScript client against a live MoltenDB server.
Built with Vite + TypeScript. No framework required.
What is this?
This project is a browser-based integration testing environment for the MoltenDB server. It contains three interactive test pages that let you exercise the HTTP API and WebSocket endpoint directly from your browser, using the @moltendb-web/query TypeScript client.
It is not a general-purpose demo — it exists to validate the server's behaviour and the type declarations of the query builder package.
Prerequisites
- Node.js 20+
- A running MoltenDB server — see the MoltenDB repo for setup instructions
- A valid TLS certificate (the server runs HTTPS-only)
Quick server start (from the MoltenDB repo)
⚠️ The credentials you use to start the server must exactly match what you enter in the login form. The server will not start without them, and login will fail if they don't match.
# Set credentials — these MUST match what you type in the login form
export MOLTENDB_ADMIN_USER=admin
export MOLTENDB_ADMIN_PASSWORD=admin123
# Run the server (default port 1538)
cargo run --release
The test pages default to https://localhost:1538 and pre-fill admin / admin123 in the login form. If you start the server with different credentials, update the login form to match — or change the environment variables above to match what you prefer.
Getting Started
npm install
npm run dev
Open http://localhost:5173 — you'll see the index page with links to all three test pages.
Test Pages
1. Fetch Collection (/fetch-collection/)
A minimal page to authenticate and fetch all documents from any named collection. Useful for quickly inspecting server state.
2. Server Query Builder (/server-query-builder/)
An interactive query builder explorer with 30 pre-built example queries covering:
- Seed data (memory, display, laptops collections)
- Basic reads (single key, batch, all documents)
- Field selection (include / exclude, deep dot-notation)
WHEREclause (all 9 operators:$eq,$ne,$gt,$gte,$lt,$lte,$in,$nin,$contains)- Sort (single and multi-field)
- Pagination (
count+offset) - Cross-collection joins
- Update (partial patch)
- Delete (single key, batch, drop)
extends(inline reference embedding at insert time)
3. WebSocket Tester (/websocket-test/)
Connect to the MoltenDB WebSocket endpoint (wss://localhost:1538/ws), authenticate with a JWT, and observe real-time push events as you write to the database from another tab or tool.
Query Builder Usage
All three pages use the @moltendb-web/query package with a custom HttpTransport:
import { MoltenDBClient, MoltenTransport, Document, JsonValue } from '@moltendb-web/query';
class HttpTransport implements MoltenTransport {
constructor(private baseUrl: string, private token: string) {}
async send(action: 'get' | 'set' | 'update' | 'delete', payload: Document): Promise<JsonValue> {
const res = await fetch(`${this.baseUrl}/${action}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.token}` },
body: JSON.stringify(payload),
});
return res.json();
}
}
const client = new MoltenDBClient(new HttpTransport('https://localhost:1538', token));
// GET — chainable query
const results = await client.collection('laptops')
.get()
.where({ brand: 'Apple', in_stock: true })
.fields(['brand', 'model', 'price'])
.sort([{ field: 'price', order: 'asc' }])
.count(5)
.exec();
Scripts
| Command | Description |
|---|---|
npm run dev | Start Vite dev server at http://localhost:5173 |
npm run build | Build all pages to dist/ |
npm run preview | Preview the production build locally |
Project Structure
moltendb-server-test/
index.html — navigation hub (links to all three pages)
fetch-collection/
index.html — markup
style.css — styles
main.ts — typed fetch + login logic
server-query-builder/
index.html — markup
style.css — styles
main.ts — 30 example queries, interactive editor
websocket-test/
index.html — markup
style.css — styles
main.ts — WebSocket connect / auth / log
vite.config.js — multi-page Vite config
tsconfig.json — TypeScript config (strict mode)
package.json
Related
- MoltenDB Server — the Rust server this project tests
@moltendb-web/queryon NPM — the TypeScript query builder- Live WASM Demo on StackBlitz — browser-only demo (no server required)