# EasyPanel API - Service Configuration

## Actualizar Source (GitHub)

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

## Actualizar Source (Git Custom)

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateSourceGit" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "repo":"https://git.descomplicar.pt/org/repo",
    "ref":"main",
    "path":"/"
  }}'
```

## Actualizar Source (Docker Image)

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

## Actualizar Environment Variables

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

## Actualizar Domains

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateDomains" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "domains":[
      {"host":"api.descomplicar.pt","https":true,"port":3000}
    ]
  }}'
```

## Actualizar Mounts

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateMounts" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "mounts":[
      {"type":"volume","name":"data","mountPath":"/app/data"}
    ]
  }}'
```

## Actualizar Ports (non-HTTP)

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updatePorts" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "ports":[
      {"published":8080,"target":3000,"protocol":"tcp"}
    ]
  }}'
```

## Actualizar Resources

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateResources" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "resources":{
      "memoryLimit":"512m",
      "memoryReservation":"256m",
      "cpuLimit":1,
      "cpuReservation":0.5
    }
  }}'
```

## Actualizar Build Config

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateBuild" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "build":{
      "type":"nixpacks",
      "buildCommand":"npm run build",
      "startCommand":"npm start"
    }
  }}'
```

## Actualizar Deploy (Replicas, Command)

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.updateAdvanced" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-api",
    "deploy":{
      "replicas":2,
      "command":"node dist/index.js",
      "zeroDowntime":true
    }
  }}'
```

## Database Backup Config

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.postgres.updateBackup" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{
    "projectName":"descomplicar",
    "serviceName":"minha-db",
    "backup":{
      "enabled":true,
      "schedule":"0 3 * * *",
      "destination":{
        "type":"s3",
        "bucket":"backups",
        "region":"eu-west-1",
        "accessKey":"...",
        "secretKey":"..."
      }
    }
  }}'
```
