# EasyPanel API - Services

## Service Types

| Type | Descricao |
|------|-----------|
| `app` | Aplicacao (Node.js, Python, Go, etc.) |
| `mysql` | MySQL database |
| `mariadb` | MariaDB database |
| `postgres` | PostgreSQL database |
| `mongo` | MongoDB database |
| `redis` | Redis cache |

## Criar Servico App

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

## Criar Servico Database

```bash
# PostgreSQL
curl -s -X POST "http://localhost:3000/api/trpc/services.postgres.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-db"}}'

# MySQL
curl -s -X POST "http://localhost:3000/api/trpc/services.mysql.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"mysql-db"}}'

# Redis
curl -s -X POST "http://localhost:3000/api/trpc/services.redis.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"cache"}}'
```

## Inspeccionar Servico

```bash
curl -s "http://localhost:3000/api/trpc/services.app.inspectService?input=%7B%22json%22%3A%7B%22projectName%22%3A%22descomplicar%22%2C%22serviceName%22%3A%22dashboard_descomplicar%22%7D%7D" \
  -H "Authorization: Bearer $TOKEN"
```

Response:
```json
{
  "projectName": "descomplicar",
  "name": "dashboard_descomplicar",
  "type": "app",
  "enabled": true,
  "token": "deploy-webhook-token",
  "source": {"type": "git", "repo": "https://...", "ref": "main"},
  "build": {"type": "nixpacks", "buildCommand": "npm run build"},
  "env": "VAR=value",
  "mounts": [],
  "ports": []
}
```

## Deploy Servico

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.deployService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

## Enable/Disable Servico

```bash
# Disable
curl -s -X POST "http://localhost:3000/api/trpc/services.app.disableService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'

# Enable
curl -s -X POST "http://localhost:3000/api/trpc/services.app.enableService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

## Destruir Servico

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.destroyService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```
