Migrate to host/id based seed node records

Instead of having one record per service, we configure the host
and expect services to run on certain ports.
This commit is contained in:
Alexis Sellier
2021-09-14 15:08:13 +02:00
parent f7511a9e17
commit 75983dc98e
10 changed files with 33 additions and 36 deletions
+5 -4
View File
@@ -5,8 +5,8 @@ export async function get(
params: Record<string, any>,
config: Config
): Promise<any> {
if (! config.seed.api) {
throw new Error("Seed HTTP API unavailable");
if (! config.seed.host) {
throw new Error("Seed host unavailable");
}
const query: Record<string, string> = {};
@@ -14,9 +14,10 @@ export async function get(
query[key] = val.toString();
}
const base = config.seed.api.replace(/\/$/, "");
const base = config.seed.host;
const port = config.seed.port;
const search = new URLSearchParams(query).toString();
const baseUrl = `${base}/v1/${path}`;
const baseUrl = `https://${base}:${port}/v1/${path}`;
const url = search ? `${baseUrl}?${search}` : baseUrl;
let response = null;