eliprtow Examples
Interactive code samples demonstrating eliprtow's capabilities across different use cases and integration scenarios.
Getting Started
Basic Project Setup
npm create-eliprtow my-project
cd my-project
npm start
// src/index.js
import { init } from '@eliprtow/core'
init({
environment: 'local',
debug: true
}).then(app => {
console.log('eliprtow initialized with:', app.config)
})
API Calls
Authentication
curl -X POST "https://api.eliprtow.dev/v1/auth" \
-H "Content-Type: application/json" \
-d '{"email":"dev@example.com","api_key":"your-key"}'
Response will include
Authorization: Bearer YOUR_TOKEN
to be used in subsequent requests.
Project Management
GET /api/v1/projects
GET /api/v1/project/{id}
POST /api/v1/project
Create, list, and manage projects through the RESTful API.
⚠️ Tip: Use POST with {"name": "New Project"} to create a new project.
Real-Time Collaboration
Live Document Editing
This interactive demo lets two nodes collaborate in real-time.
Local timestamp:
Sync status: Not connected
Connected users: 0
⚠️ Simulation: This is a mock real-time sync demo. Actual implementation would use WebRTC and CRDT structures for real collaboration.
Real-Time Node Connection
import { createNode } from '@eliprtow/core';
const node = createNode({
id: 'user-123',
host: 'wss://my-project.eliprtow.dev'
});
node.on('connect', () => {
console.log('Connected to network with', node.connections.length, 'active peers');
node.state.doc = 'Initial document content';
});
from eliprtow import Node
node = Node(
node_id='user-123',
host='wss://my-project.eliprtow.dev'
)
@node.on_connect
def handle_connect():
print(f"Connected with {len(node.connections)} peers")
node.set_state({'doc': 'Initial content'})
UI Integrations
Chat Integration
Create real-time chat applications using the peer-to-peer connections.
👋 Welcome to the chat!
How does sync work?
File Upload Widget
Example of integrating file drag-and-drop with the eliprtow file API.
Drag and drop files or
Supports all common document types
Advanced Patterns
CRDT Conflict Resolution
Example showing CRDT-based sync between two nodes modifying the same document.
const NodeA = createNode({
state: { doc: 'Original content' }
});
const NodeB = createNode({
state: 'Updated content'
});
// Automatic merge using CRDT
const merged = eliprtow.mergeStates(NodeA.state, NodeB.state);
console.log(merged.doc); // Outputs both content using conflict markers
Performance Optimization
-
✅ Use
optimizeState()
for large payload compression -
✅ Implement delta encoding with
syncDeltas()
-
✅ Enable
throttleSync(1000)
for network optimization
node.throttleSync(1000); // Throttle updates to 1 second intervals
node.optimizeState(); // Compress document before sending
node.syncDeltas(); // Only send changed document parts