# Reference

```typescript
interface WorkerMetadata {
  queue: string;
  endpoint: EndpointOptions;
  opts?: WorkerOptions;
}
```

```typescript
interface EndpointOptions {
    url: string;
    method: "post" | "get" | "put" | "delete" | "patch";
    headers?: Record<string, string>;
    timeout?: number; // max allowed duration in milliseconds
}
```

```typescript
interface WorkerOptions {
  concurrency?: number;
  limiter?: {
    max: number; // integer representing max number of jobs to process on "duration"
    duration: number: // number of millisecons
  };
  removeOnComplete?: {
    count?: number;
    age?: number;
  };
  removeOnFail?: {
    count?: number;
    age?: number;
  };
  maxStalledCount?: number;
}
```

## Workers API

## Add / Update a worker

<mark style="color:green;">`POST`</mark> `/workers`

Adds a new worker or updates an existing one.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name       | Type          | Description            |
| ---------- | ------------- | ---------------------- |
| `queue`    | string        | Name of the queue      |
| `endpoint` | Endpoint      | Endpoint options       |
| `opts`     | WorkerOptions | Options for the worker |

**Response**

{% tabs %}
{% tab title="200" %}

```
"OK"
```

{% endtab %}

{% tab title="400" %}

```json
Error message depending on the cause of the error
```

{% endtab %}
{% endtabs %}

## Remove worker

<mark style="color:green;">`DELETE`</mark> `/workers/:queue-name`

Removes an existing worker for a given queue.

**Headers**

| Name          | Value            |
| ------------- | ---------------- |
| Authorization | `Bearer <token>` |

**Response**

{% tabs %}
{% tab title="200" %}

```json
"OK"
```

{% endtab %}

{% tab title="404" %}

```
"Worker not found"
```

{% endtab %}
{% endtabs %}

## Get workers

<mark style="color:green;">`GET`</mark> `/workers`

Gets all the workers registered in the proxy.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "queue-name": "url"
}
```

{% endtab %}
{% endtabs %}
