feat(init): apply base URL template to discovered apps
Discovered Docker apps now use the same buildAppUrl logic as integrations when a base host is set, instead of using the raw Docker socket URL (e.g. http://container:5432). Extracts shared buildUrl helper and adds buildAppUrl that derives a slug from the container name. Also passes publishedPort through the DiscoveredApp type so host:port mode works correctly.
This commit is contained in:
1 parent
bbb04b084f
commit
7c0653672a
4 files changed
+36
-18
No files matched your search
@@ -6,6 +6,14 @@ export type UrlTemplateMode = "hostPort" | "subdomain";
|
||||
|
||||
const getSlugForKind = (kind: IntegrationKind): string => integrationIconSlugs[kind];
|
||||
|
||||
const buildUrl = (slug: string, host: string, mode: UrlTemplateMode, port?: number): string => {
|
||||
const modeBuilders: Record<UrlTemplateMode, () => string> = {
|
||||
subdomain: () => `https://${slug}.${host}`,
|
||||
hostPort: () => (port ? `http://${host}:${port}` : `http://${host}`),
|
||||
};
|
||||
return modeBuilders[mode]();
|
||||
};
|
||||
|
||||
export const buildIntegrationUrl = (
|
||||
kind: IntegrationKind,
|
||||
baseHost: string,
|
||||
@@ -14,16 +22,18 @@ export const buildIntegrationUrl = (
|
||||
): string => {
|
||||
const host = baseHost.trim().replace(/\/+$/, "");
|
||||
if (!host) return "";
|
||||
|
||||
const slug = getSlugForKind(kind);
|
||||
|
||||
const modeBuilders: Record<UrlTemplateMode, () => string> = {
|
||||
subdomain: () => `https://${slug}.${host}`,
|
||||
hostPort: () => {
|
||||
const port = dockerPort ?? getIntegrationDefaultPort(kind);
|
||||
return port ? `http://${host}:${port}` : `http://${host}`;
|
||||
},
|
||||
};
|
||||
|
||||
return modeBuilders[mode]();
|
||||
const port = dockerPort ?? getIntegrationDefaultPort(kind);
|
||||
return buildUrl(getSlugForKind(kind), host, mode, port ?? undefined);
|
||||
};
|
||||
|
||||
export const buildAppUrl = (
|
||||
containerName: string,
|
||||
baseHost: string,
|
||||
mode: UrlTemplateMode,
|
||||
dockerPort?: number,
|
||||
): string => {
|
||||
const host = baseHost.trim().replace(/\/+$/, "");
|
||||
if (!host) return "";
|
||||
const slug = containerName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
||||
return buildUrl(slug, host, mode, dockerPort);
|
||||
};
|
||||
Reference in new issue
Block a user