# How to Test Health API Through Domain

## Quick Test Commands

### 1. Using curl (Command Line)

**HTTP (if not using SSL):**
```bash
curl http://aibitadmin.aibitsoft.cloud/api/health
```

**HTTPS (recommended):**
```bash
curl https://aibitadmin.aibitsoft.cloud/api/health
```

**With JSON formatting:**
```bash
curl -s https://aibitadmin.aibitsoft.cloud/api/health | jq .
```

**Expected Response:**
```json
{
  "status": "ok",
  "timestamp": "2026-03-06T11:15:58.210Z",
  "environment": "production"
}
```

### 2. Using Browser

Simply open your browser and navigate to:
- **HTTP:** `http://aibitadmin.aibitsoft.cloud/api/health`
- **HTTPS:** `https://aibitadmin.aibitsoft.cloud/api/health`

You should see a JSON response with the health status.

### 3. Using Postman

1. Open Postman
2. Create a new GET request
3. Enter URL: `https://aibitadmin.aibitsoft.cloud/api/health`
4. Click "Send"
5. You should see the JSON response

### 4. Using JavaScript (Browser Console)

```javascript
fetch('https://aibitadmin.aibitsoft.cloud/api/health')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
```

### 5. Using wget

```bash
wget -qO- https://aibitadmin.aibitsoft.cloud/api/health
```

## Testing All API Endpoints

### Health Check
```bash
curl https://aibitadmin.aibitsoft.cloud/api/health
```

### Jobs API
```bash
# List all jobs
curl https://aibitadmin.aibitsoft.cloud/api/jobs

# Get specific job
curl https://aibitadmin.aibitsoft.cloud/api/jobs/6981f56823b252b43ae52691
```

### Templates API
```bash
# List all templates
curl https://aibitadmin.aibitsoft.cloud/api/templates

# Get specific template
curl https://aibitadmin.aibitsoft.cloud/api/templates/69a95055fde89403bd5c73fe
```

### Applications API
```bash
# List all applications
curl https://aibitadmin.aibitsoft.cloud/api/applications
```

### Blogs API
```bash
# List all blogs
curl https://aibitadmin.aibitsoft.cloud/api/blogs

# Get blog by category
curl https://aibitadmin.aibitsoft.cloud/api/blogs/category/tech
```

### Team Members API
```bash
# List all team members
curl https://aibitadmin.aibitsoft.cloud/api/team-members
```

### Zoom Meetings API
```bash
# List all zoom meetings
curl https://aibitadmin.aibitsoft.cloud/api/zoom-meetings
```

### User Resumes API
```bash
# List all user resumes
curl https://aibitadmin.aibitsoft.cloud/api/user-resumes
```

## Troubleshooting

### If you get "No input file specified" or 404 error:

1. **Check if Apache mod_proxy is enabled:**
   - Contact your hosting provider to enable `mod_proxy` and `mod_proxy_http`
   - Or use cPanel's Node.js Selector instead

2. **Check if the app is running:**
   ```bash
   pm2 status
   ```

3. **Check if port 4001 is accessible:**
   ```bash
   curl http://localhost:4001/api/health
   ```

4. **Check .htaccess file:**
   - Make sure the proxy rules are in place
   - File location: `/home/aibitsofts/public_html/aibitadmin.aibitsoft.cloud/.htaccess`

### Alternative: Use cPanel Node.js Selector

If Apache proxy doesn't work, use cPanel's Node.js Selector:

1. Log into cPanel
2. Find "Node.js Selector" or "Setup Node.js App"
3. Create/Edit application:
   - **Application root:** `/home/aibitsofts/public_html/aibitadmin.aibitsoft.cloud`
   - **Application URL:** `aibitadmin.aibitsoft.cloud`
   - **Application startup file:** `dist/server.js`
   - **Application port:** `4001`
   - **Node.js version:** Latest LTS

4. The Node.js Selector will handle the reverse proxy automatically

## Current Configuration

- **Local Port:** 4001
- **PM2 Process:** `aibitadmin-backend`
- **Domain:** `aibitadmin.aibitsoft.cloud`
- **API Base URL:** `https://aibitadmin.aibitsoft.cloud/api`

## Test Script

You can use this script to test all endpoints:

```bash
#!/bin/bash
DOMAIN="https://aibitadmin.aibitsoft.cloud"

echo "Testing Health API..."
curl -s "$DOMAIN/api/health" | jq .

echo -e "\nTesting Jobs API..."
curl -s "$DOMAIN/api/jobs" | jq '.success'

echo -e "\nTesting Templates API..."
curl -s "$DOMAIN/api/templates" | jq '.success'

echo -e "\nTesting Applications API..."
curl -s "$DOMAIN/api/applications" | jq '.success'

echo -e "\nTesting Blogs API..."
curl -s "$DOMAIN/api/blogs" | jq '.success'

echo -e "\nTesting Team Members API..."
curl -s "$DOMAIN/api/team-members" | jq '.success'

echo -e "\nTesting Zoom Meetings API..."
curl -s "$DOMAIN/api/zoom-meetings" | jq '.success'

echo -e "\nTesting User Resumes API..."
curl -s "$DOMAIN/api/user-resumes" | jq '.success'
```

Save this as `test-api.sh`, make it executable (`chmod +x test-api.sh`), and run it.
