The Database Management API Server is a backend system designed to manage PostgreSQL databases entirely via APIs. It provides endpoints for authentication, database operations, and monitoring, making it easy to integrate database management into your applications.
- API Key Management: Role-based access control (
admin
,full-access
,read-only
). - Permanent Admin API Key: A secure, non-editable admin key for critical operations.
- First-Time Setup Logic: Create API keys without authentication if no keys exist.
- Health Monitoring: Check the health of the API and database.
- Swagger Documentation: Interactive API documentation.
- Rate Limiting: Prevent abuse with configurable rate limits.
- CORS Support: Secure cross-origin requests.
- Node.js (v18 or higher)
- PostgreSQL
- Redis (optional, for queues and rate-limits)
- Clone the repository:
git clone https://github.com/<your-username>/DB-API-Server.git cd DB-API-Server
- Install dependencies:
npm install
- Configure environment variables:
- Create a
.env
file based on.env.example
. - Set the required variables (e.g.,
DATABASE_URL
,JWT_SECRET
,ADMIN_API_KEY
).
- Create a
- Start the server:
npm run dev
- Health Check:
GET /health
- API Documentation:
GET /docs
- Authentication:
POST /api/auth
- Database Operations:
POST /api/db
- Status Monitoring:
GET /api/status
Use the permanent admin API key (ADMIN_API_KEY
) for critical operations. Example:
curl -H "X-API-Key: <admin-api-key>" http://localhost:8080/api/status
npm run dev
npm test
npm run lint
- Install PM2:
npm install -g pm2
- Start the server:
npm run start:pm2
- Monitor the server:
npm run status:pm2
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For support, contact support@example.com.