// AUTO-GENERATED by puerto. Edit puerto.toml, then run `puerto generate bootstrap`.
//
// The composition root: the only module that imports `infrastructure/`. Screens reach the
// adapters through `useDependencies()`, so a test hands them a fake instead.
{% if entities or auth %}
{% if auth -%}
{% if local -%}
import type { Accounts } from "../../../domain/auth/accounts";
{% endif -%}
import type { AuthGateway } from "../../../domain/auth/session";
{% if local -%}
import { localAuthGateway } from "../../../infrastructure/auth/local-auth-gateway";
{% else -%}
import { oidcAuthGateway, oidcSettingsFromEnv } from "../../../infrastructure/auth/oidc-auth-gateway";
{% endif -%}
{% if entities -%}
import { bearerMiddleware } from "../../../infrastructure/auth/bearer-middleware";
{% endif -%}
{% endif -%}
{% for e in entities -%}
import type { {{ e.pascal }}Repository } from "../../../domain/{{ e.kebab }}/repository";
import { {{ e.camel }}RepositoryHttp } from "../../../infrastructure/{{ e.kebab }}/{{ e.kebab }}-repository-http";
{% endfor -%}
{% if entities -%}
import { createApiClient } from "../../../infrastructure/http/client";
{% endif %}
export interface Dependencies {
{%- if local %}
accounts: Accounts;
{%- endif %}
{%- if auth %}
auth: AuthGateway;
{%- endif %}
{%- for e in entities %}
{{ e.camel }}Repository: {{ e.pascal }}Repository;
{%- endfor %}
}
export function createDependencies(): Dependencies {
{%- if auth %}
const auth = {% if local %}localAuthGateway(){% else %}oidcAuthGateway(oidcSettingsFromEnv()){% endif %};
{%- endif %}
{%- if entities %}
const api = createApiClient();
{%- if auth %}
api.use(bearerMiddleware(auth));
{%- endif %}
{%- endif %}
return {
{%- if local %}
accounts: auth,
{%- endif %}
{%- if auth %}
auth,
{%- endif %}
{%- for e in entities %}
{{ e.camel }}Repository: {{ e.camel }}RepositoryHttp(api),
{%- endfor %}
};
}
{%- else %}
export type Dependencies = Record<string, never>;
export function createDependencies(): Dependencies {
return {};
}
{%- endif %}