Skip to content

Bif12/DB-API-Server

Repository files navigation

Database Management API Server

Overview

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.

Features

  • 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.

Installation

Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL
  • Redis (optional, for queues and rate-limits)

Steps

  1. Clone the repository:
    git clone https://github.com/<your-username>/DB-API-Server.git
    cd DB-API-Server
  2. Install dependencies:
    npm install
  3. Configure environment variables:
    • Create a .env file based on .env.example.
    • Set the required variables (e.g., DATABASE_URL, JWT_SECRET, ADMIN_API_KEY).
  4. Start the server:
    npm run dev

Usage

API Endpoints

  • Health Check: GET /health
  • API Documentation: GET /docs
  • Authentication: POST /api/auth
  • Database Operations: POST /api/db
  • Status Monitoring: GET /api/status

Admin API Key

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

Development

Run in Watch Mode

npm run dev

Run Tests

npm test

Lint Code

npm run lint

Deployment

Using PM2

  1. Install PM2:
    npm install -g pm2
  2. Start the server:
    npm run start:pm2
  3. Monitor the server:
    npm run status:pm2

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For support, contact support@example.com.

About

its api manger for database postgres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published