baas-frontend-client
v1.0.0
Published
BAAS Frontend Client - Direct API calls for React/Vue/Angular apps
Maintainers
Readme
🚀 BAAS Frontend Client
Direct API calls for React/Vue/Angular apps - No backend setup required!
📋 Overview
BAAS Frontend Client lets you use BAAS services directly from your frontend applications without setting up any backend server. Just provide your API key and Project ID!
🎯 Features
- ✅ Zero Setup: No backend server required
- ✅ Direct API Calls: Calls deployed BAAS backend directly
- ✅ Browser Compatible: Works in React, Vue, Angular, vanilla JS
- ✅ TypeScript Ready: Full TypeScript support
- ✅ Error Handling: Built-in error handling and validation
- ✅ All APIs: Auth, Database, Storage, Analytics
🚀 Quick Start
Installation
npm install @darshan022/baas-clientBasic Usage
import BAASClient from "@darshan022/baas-client";
// Initialize client
const baas = new BAASClient("pk_live_your_api_key", "your_project_id");
// Use APIs directly
const result = await baas.signup("[email protected]", "password123");
console.log(result);📱 React Example
import React, { useState } from "react";
import BAASClient from "@darshan022/baas-client";
const MyComponent = () => {
const [baas] = useState(new BAASClient("your-api-key", "your-project-id"));
const [loading, setLoading] = useState(false);
const [result, setResult] = useState(null);
const handleSignup = async () => {
setLoading(true);
try {
const result = await baas.signup("[email protected]", "password123");
setResult(result);
} catch (error) {
console.error("Signup failed:", error.message);
} finally {
setLoading(false);
}
};
return (
<div>
<button onClick={handleSignup} disabled={loading}>
{loading ? "Signing up..." : "Sign Up"}
</button>
{result && <pre>{JSON.stringify(result, null, 2)}</pre>}
</div>
);
};🔧 API Reference
Authentication
// Signup
await baas.signup("[email protected]", "password123", "username");
// Login
await baas.login("[email protected]", "password123");Database
// Query
await baas.queryDatabase("users", 10);
// Insert
await baas.insertData("users", { name: "John", email: "[email protected]" });
// Update
await baas.updateData("users", { id: 1 }, { name: "John Updated" });
// Delete
await baas.deleteData("users", { id: 1 });Storage
// Upload
await baas.uploadFile("document.pdf", "base64-content", "application/pdf");
// List files
await baas.listFiles();
// Download
await baas.downloadFile("document.pdf");Analytics
// Usage stats
await baas.getUsageStats();
// Performance metrics
await baas.getPerformanceMetrics();
// Project stats
await baas.getProjectStats();System
// API info
await baas.getApiInfo();
// Health check
await baas.healthCheck();
// Test connection
await baas.testConnection();⚙️ Configuration
const baas = new BAASClient(apiKey, projectId, {
baseUrl: "https://your-custom-backend.com", // Optional
timeout: 10000, // Optional, default 10s
});🔍 Error Handling
try {
const result = await baas.signup("[email protected]", "password123");
console.log("Success:", result);
} catch (error) {
console.error("Error:", error.message);
// Handle error appropriately
}🌐 Browser Support
- ✅ Chrome 60+
- ✅ Firefox 55+
- ✅ Safari 12+
- ✅ Edge 79+
📦 Bundle Size
- Minified: ~5KB
- Gzipped: ~2KB
🔗 Links
- Backend Package:
@darshan022/baas-platform(for Node.js apps) - Documentation: [Coming Soon]
- Support: [GitHub Issues]
📄 License
MIT License - see LICENSE file for details.
Ready to build amazing frontend apps with BAAS! 🚀
