bindra
v2.1.0
Published
Lightweight reactive data management library for TypeScript applications
Maintainers
Readme
Bindra
Bindra is a lightweight, reactive data management library for TypeScript applications. It provides a unified API for managing both local and remote data with built-in reactivity, validation, caching, and real-time updates.
✨ Features
- 🎯 Type-Safe: Full TypeScript support with comprehensive type definitions
- 🔄 Reactive: Built-in reactivity with signals and reactive objects
- 🌐 API Ready: Seamless REST API integration with automatic retries
- ✅ Validation: Comprehensive validation system with custom rules
- 💾 Caching: Smart TTL-based caching to reduce API calls
- 📄 Pagination: Offset and cursor-based pagination strategies
- 🔌 Real-time: WebSocket support with auto-reconnect
- 📦 Zero Dependencies: Pure TypeScript, no external dependencies
- 🎨 Framework Agnostic: Works with React, Vue, Svelte, or vanilla JS
📦 Installation
npm install bindra
# or
pnpm add bindra
# or
yarn add bindra🚀 Quick Start
import { DataSource } from 'bindra';
interface User {
id: number;
name: string;
email: string;
}
// Create a DataSource
const users = new DataSource<User>({
url: '/api/users'
});
// Fetch data
await users.fetch();
// Create a record
const newUser = await users.create({
name: 'Alice',
email: '[email protected]'
});
// Update a record
await users.update(1, { name: 'Bob' });
// Delete a record
await users.delete(1);
// Subscribe to changes
users.on('created', (user) => {
console.log('User created:', user);
});📚 Documentation
For complete documentation, visit: https://bindra-docs.web.app
💡 Key Concepts
DataSource
The main class for managing data:
const ds = new DataSource<Product>({
url: '/api/products',
cache: { enabled: true, ttl: 300000 },
pagination: { pageSize: 20 }
});Validation
Built-in validation system:
const users = new DataSource<User>({
url: '/api/users',
fields: [
{
name: 'email',
validation: {
required: true,
type: 'email'
}
},
{
name: 'age',
validation: {
type: 'number',
min: 18,
max: 120
}
}
]
});Real-time Updates
WebSocket support for live data:
const messages = new DataSource<Message>({
url: '/api/messages',
realtime: {
enabled: true,
url: 'wss://api.example.com/ws',
reconnect: true
}
});
messages.on('realtime:message', (data) => {
console.log('New message:', data);
});🎯 Use Cases
Bindra is perfect for:
- ✅ CRUD applications
- ✅ Data-heavy dashboards
- ✅ Real-time collaborative apps
- ✅ Forms with validation
- ✅ Paginated lists
- ✅ Infinite scroll
🧪 Testing
Bindra is thoroughly tested with 155+ tests:
cd package
pnpm test📄 License
MIT License - see LICENSE for details
🤝 Contributing
See CONTRIBUTING.md for contribution guidelines.
🔗 Links
📦 What's Included
[email protected]
├── dist/
│ ├── index.js # Main entry point
│ ├── index.d.ts # TypeScript definitions
│ ├── core/ # Core modules
│ └── utils/ # Utility functions
├── README.md
├── LICENSE
└── CHANGELOG.md🚀 Quick Examples
Local Data
const todos = new DataSource<Todo>({
data: [
{ id: 1, title: 'Learn Bindra', completed: false },
{ id: 2, title: 'Build app', completed: false }
]
});Remote API
const users = new DataSource<User>({
url: 'https://api.example.com/users',
cache: { enabled: true, ttl: 300000 }
});With Validation
const products = new DataSource<Product>({
url: '/api/products',
fields: [
{
name: 'name',
validation: { required: true, type: 'string', min: 3 }
},
{
name: 'price',
validation: { required: true, type: 'number', min: 0 }
}
]
});Built with ❤️ for the TypeScript community
