A simple data streaming mock server built with Bun + TypeScript.
- Bun installed on your machine
You can install Streamock globally using npm:
npm install -g streamockOr using bun:
bun install -g streamockStart the server:
streamock startThis will start a server at http://localhost:3001
Streamock provides a complete set of process management commands:
# Start server (foreground)
streamock start
streamock start -p 8080 # Custom port
# Start in background (daemon mode)
streamock start -d
# Stop server
streamock stop
streamock stop -p 8080 # Stop specific port
# Restart server
streamock restart
# Check status
streamock statusStreamock automatically checks for updates when you start the server. The update uses npm for better stability.
Control auto-update behavior:
# Skip version check
export STREAMOCK_SKIP_VERSION_CHECK=true
streamock start
# Force update requirement
export STREAMOCK_FORCE_UPDATE=true
streamock start
# Disable auto-update (check only)
export STREAMOCK_AUTO_UPDATE=false
streamock startManual update:
# Recommended: Use npm for stability
npm install -g streamock@latest
# Or use your preferred package manager
bun add -g streamock@latest
pnpm add -g streamock@latest
yarn global add streamock@latest# Development: Start in foreground
streamock start
# Production: Start in background
streamock start -d
# View logs
tail -f /tmp/streamock-3001.log
# Restart after updates
streamock restartStreamock supports template variables in your mock data using {{variable_name}} syntax:
1. Add variables in your data:
data: {"session_id": "{{session_id}}", "query": "{{query}}", "action": "chat"}2. System auto-detects variables:
- Click "Start Streaming" - auto-generates random values
- Or call API with parameters:
curl -X POST "http://localhost:3001/api/stream" \
-H "Content-Type: application/json" \
-d '{"session_id": "test-123", "query": "buy me a tv"}'- Auto: Automatically extracted from requests or randomly generated
- Fixed: Use fixed values
| Variable Name | Generated Value |
|---|---|
Contains id, session |
UUID v4 format |
Contains query, text |
Random example queries |
Contains user |
User ID format |
| Others | Generic random values |
- Clone the repository:
git clone https://github.com/Wangggym/streamock.git
cd streamock- Install dependencies:
bun install- Start in development mode:
bun run dev- Build the project:
bun run build- Run tests:
# Run all unit tests
bun test
# Test storage location functionality
bun run test:storageFor detailed testing information, see TESTING.md
streamock/
├── src/
│ ├── server.ts # Main server implementation
│ ├── cli.ts # CLI implementation
│ └── devServer.ts # Server runner
├── dist/ # Compiled JavaScript files
├── index.html # Web interface
└── package.json # Project configuration
- The server serves a single HTML page with a form and a results area
- When the user submits data:
- The form submission is handled via a POST request to
/submit - A Server-Sent Events connection is established via
/stream
- The form submission is handled via a POST request to
- The server streams the data back to the client with configurable options:
- Line combination: Combine multiple lines using specified range
- Custom separators: Use custom separators between lines
- Real-time updates: See the streaming data immediately
- Stream data with customizable delay
- Combine multiple lines with custom separator
- Web interface for data input and streaming
- Real-time data updates
- Support for custom separators and line combinations
- Built with Bun for better performance
- Written in TypeScript for type safety
- iCloud sync support for Mac users - automatically sync data across your devices
Your mock data is automatically stored in iCloud Drive at:
~/Library/Mobile Documents/com~apple~CloudDocs/.streamock-data/
This means:
- ✅ Data syncs automatically across all your Mac devices
- ✅ No manual setup required - just sign in to iCloud
- ✅ Your mock data is always backed up
- 💡 If iCloud is unavailable, it automatically falls back to local storage
Data is stored locally at:
~/.streamock-data/
When you start the server, it will display the storage location:
streamock start
# Output:
# ✅ Server running at http://localhost:3001
# 💾 Data storage: /Users/yourname/Library/Mobile Documents/com~apple~CloudDocs/.streamock-data
# 💡 Press Ctrl+C to stop the serverGET /: Serves the web interfacePOST /submit: Updates the server's data cacheGET /stream: Streams the data back to the client
The server can be configured with the following options:
interface ServerConfig {
port: number; // Default: 3001
// ... other Bun.serve options
}MIT License - see the LICENSE file for details
For more information, to report issues, or to contribute, please visit: https://github.com/Wangggym/streamock
