82 أسطر
1.8 KiB
Markdown
82 أسطر
1.8 KiB
Markdown
# Ghayma REST API Application
|
|
|
|
A simple, lightweight Node.js Express REST API application with container support.
|
|
|
|
## 🚀 Features
|
|
|
|
- **Express.js** lightweight web framework
|
|
- **CORS & JSON Middleware** pre-configured
|
|
- **Health Check Endpoint** (`/health`) for Docker/Kubernetes probes
|
|
- **Resource CRUD API** (`/api/v1/items`)
|
|
- **Docker Support** with health checks and optimized `.dockerignore`
|
|
|
|
---
|
|
|
|
## 🛠️ Endpoints Overview
|
|
|
|
| Method | Endpoint | Description |
|
|
| :--- | :--- | :--- |
|
|
| `GET` | `/` | API Metadata & Welcome Info |
|
|
| `GET` | `/health` | Application Health & Uptime Status |
|
|
| `GET` | `/metrics` | API Request Metrics (Latency, Counts, Status) |
|
|
| `GET` | `/dashboard` | API Internal Monitoring Dashboard UI |
|
|
| `GET` | `/monitoring` | External Platform Monitoring Dashboard (mithal.space) |
|
|
| `GET` | `/api/monitoring/metrics` | External Monitoring Data (from Python collector) |
|
|
| `GET` | `/api/v1/items` | List all items |
|
|
| `GET` | `/api/v1/items/:id` | Get item by ID |
|
|
| `POST` | `/api/v1/items` | Create new item |
|
|
| `DELETE` | `/api/v1/items/:id` | Delete item by ID |
|
|
|
|
---
|
|
|
|
## 💻 Running Locally
|
|
|
|
### Prerequisites
|
|
- Node.js (v18+)
|
|
|
|
### Steps
|
|
1. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Start the API server:
|
|
```bash
|
|
npm start
|
|
```
|
|
Or for development auto-reload (Node 18+):
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
3. Test the server:
|
|
Navigate to `http://localhost:3000` or run:
|
|
```bash
|
|
curl http://localhost:3000/health
|
|
```
|
|
|
|
---
|
|
|
|
## 🐳 Running with Docker
|
|
|
|
### Build the Docker Image
|
|
```bash
|
|
docker build -t ghayma-api .
|
|
```
|
|
|
|
### Run the Container
|
|
```bash
|
|
docker run -d -p 3000:3000 --name ghayma-api-app ghayma-api
|
|
```
|
|
|
|
### Test Containerized API
|
|
```bash
|
|
curl http://localhost:3000/api/v1/items
|
|
```
|
|
|
|
### Stop Container
|
|
```bash
|
|
docker stop ghayma-api-app
|
|
docker rm ghayma-api-app
|
|
```
|