@darshan022/baas-platform
v1.0.3
Published
Backend-as-a-Service platform with Authentication, Database, and Storage APIs
Maintainers
Readme
BAAS Platform
Cloud-Native Backend-as-a-Service - Zero setup, instant backend APIs. No servers, no databases, no configuration required!
🚀 Quick Start
1. Get Your API Key
Visit your-dashboard.com to:
- Create a project
- Generate your API key
- Get your Project ID
2. Install & Use
npm install baas-platform3. Basic Usage
const BAAS = require("baas-platform");
const baas = new BAAS({
apiKey: "pk_live_your_api_key_here",
projectId: "your_project_id",
port: 3000, // Optional: defaults to 3000
});
baas.start();That's it! 🎉 Your backend is ready with Auth, Database, and Storage APIs.
Using CLI Tool
# Install globally
npm install -g baas-platform
# Initialize a new project
baas init my-project
cd my-project
npm install
npm start⚙️ Configuration
Required Configuration
const baas = new BAAS({
apiKey: "pk_live_your_api_key_here", // Required: Get from dashboard
projectId: "your_project_id", // Required: Get from dashboard
});Optional Configuration
const baas = new BAAS({
apiKey: "pk_live_your_api_key_here",
projectId: "your_project_id",
port: 3000, // Optional: Server port (default: 3000)
baseUrl: "https://hack-cbs-project-backend-1.vercel.app", // Optional: Custom API endpoint
corsOrigins: ["http://..."], // Optional: Allowed CORS origins
rateLimit: 300, // Optional: Rate limit per 15 minutes
trackingEnabled: true, // Optional: Enable usage tracking (default: true)
});Environment Variables
Create a .env file:
BAAS_API_KEY=pk_live_your_api_key_here
BAAS_PROJECT_ID=your_project_id
BAAS_BASE_URL=https://hack-cbs-project-backend-1.vercel.app
PORT=3000
NODE_ENV=production🌐 How It Works
Cloud-Native Architecture
The BAAS NPM package acts as a smart proxy that:
- Receives requests on your local server (port 3000)
- Validates API key and project ID automatically
- Forwards requests to the cloud backend
- Tracks usage for analytics and billing
- Returns responses to your application
Zero Setup Required
- ❌ No MongoDB setup - Cloud database handles everything
- ❌ No server configuration - Just run and go
- ❌ No environment setup - Only API key needed
- ❌ No scaling concerns - Cloud handles all traffic
- ✅ Instant backend - Auth, Database, Storage ready
📊 Usage Tracking & Analytics
Every API call is automatically tracked for:
What's Tracked:
- API endpoint usage - Which endpoints are called
- Response times - Performance metrics
- Success/failure rates - Error tracking
- Request volume - Usage patterns
- Project analytics - Per-project insights
Privacy & Security:
- API key validation - Secure authentication
- Project isolation - Data separated by project
- No personal data - Only technical metrics
- Opt-out available - Set
trackingEnabled: false
View Analytics:
Visit your dashboard at your-dashboard.com to see:
- Real-time usage metrics
- Performance analytics
- Error monitoring
- Usage billing
📚 Available APIs
Authentication APIs
POST /api/auth/signup- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logout
Database APIs
GET /api/db/query- Query recordsPOST /api/db/insert- Insert recordsPUT /api/db/update- Update recordsDELETE /api/db/delete- Delete records
Storage APIs
POST /api/storage/upload- Upload filesGET /api/storage/download- Download filesDELETE /api/storage/delete- Delete files
Management APIs
GET /api/keys- List API keysPOST /api/keys- Create API keyDELETE /api/keys/:id- Delete API keyGET /api/usage/stats/:projectId- Usage statistics
🔑 API Key Management
Generate API Key
// Generate API key
const apiKey = await baas.generateApiKey({
name: "My App Key",
permissions: ["auth", "database", "storage"],
});
console.log(apiKey); // pk_live_...Using API Keys
// Make authenticated requests
fetch("/api/auth/signup", {
method: "POST",
headers: {
"x-api-key": "pk_live_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "[email protected]",
password: "password123",
}),
});🐳 Docker Deployment
Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]Docker Compose
version: "3.8"
services:
baas:
build: .
ports:
- "3000:3000"
environment:
- MONGODB_URI=mongodb://mongo:27017/baas
- JWT_SECRET=your-secret-key
depends_on:
- mongo
mongo:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
volumes:
mongo_data:Run with Docker
docker run -p 3000:3000 \
-e MONGODB_URI=mongodb://your-db:27017/app \
-e JWT_SECRET=your-secret \
baas-platform:latest🌐 Cloud Deployment
Vercel
{
"version": 2,
"builds": [
{
"src": "server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "server.js"
}
]
}Railway
[build]
builder = "NIXPACKS"
[deploy]
healthcheckPath = "/health"
restartPolicyType = "ON_FAILURE"📊 Usage Analytics
The platform includes built-in usage tracking:
- API call counts
- Response times
- Error rates
- Endpoint usage statistics
Access analytics at: GET /api/usage/stats/:projectId
🛠 Development
Local Development
# Clone the repository
git clone https://github.com/yourusername/baas-platform.git
cd baas-platform
# Install dependencies
npm install
# Start development server
npm run devTesting
npm test📝 License
MIT License - see LICENSE file for details.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
📞 Support
- 📧 Email: [email protected]
- 📖 Documentation: https://docs.yourcompany.com
- 🐛 Issues: https://github.com/yourusername/baas-platform/issues
