# ui-middleware

> Provides the collected manifest.json of services in a cluster as well as a list of dependencies
> for each source file. This information can be used to dynamically compile all ui components at
> runtime in the browser. Besides serving the information about all resources, this service can
> also function to provide snapshots of all the resources available at a specific point in time.

## Endpoint

- `/manifests`
- `/dependencies`

## Deployments

**local**

- adjust `.env`
- run `yarn dev`

**docker**

```
docker build -t ui-middleware .
docker run -t -i -p 8080:8080 ui-middleware
```

**kubernetes**

```
cd helm
helm upgrade -i -f ui-middleware/values.yaml -f values/develop.yaml ui-middleware ./ui-middleware
```

It is possible to horizontally scale the UI Middleware, as more clients are fetching resources from this service. Each instance maintains a cache of all files locally (in memory), allowing to scale easily.

## Configuration

**local, docker**

| Parameter       | Description                     | Default  |
|-----------------|---------------------------------|----------|
| `PORT`          | Exposed port                    | `"8080"` |
| `CACHE_TTL`     | Vite manifest caching time      | `30000`  |
| `LOG_LEVEL`     | Pino log level                  | `"info"` |

**kubernetes**

| Parameter      | Description                     | Default  |
|----------------|---------------------------------|----------|
| `port`         | Exposed port                    | `"8080"` |
| `cacheTTL`     | Vite manifest caching time      | `30000`  |
| `logLevel`     | Pino log level                  | `"info"` |

## Ingress

When using Ingress to make the service available to the public, the service is intended to be
configured as a "fallback" or "default" service to answer all requests that are not specified
to be served by one of the other services (e.g like everything under /api). This should simplify
the Ingress configuration. One example can be found
[in the ui-middleware repository](https://gitlab.open-xchange.com/frontend/Infrastructure/ui-middleware/-/blob/main/.gitlab-ci/kubernetes-resources.yaml).