Files
radicle-explorer/src/lib/config.ts
T
Sebastian Martinez 2fc03f3312 Add apiVersion to config and httpd request
We have a new apiVersion value in the config json that needs to be
changed for each breaking change on httpd so we can simulate a new
resource to the cache and get it cleared.

Also improves the ResponseParseError giving the user more information
on, if the node or the web client is outdated
2024-05-03 08:34:08 +02:00

49 lines
1.2 KiB
TypeScript

import type { BaseUrl } from "@httpd-client";
import configJson from "@app/config.json";
export interface Config {
nodes: {
apiVersion: string;
fallbackPublicExplorer: string;
defaultHttpdPort: number;
defaultHttpdHostname: string;
defaultLocalHttpdPort: number;
defaultNodePort: number;
defaultHttpdScheme: string;
pinned: { baseUrl: BaseUrl }[];
};
supportWebsite: string;
fallbackPreferredSeed: BaseUrl;
}
function getConfig(): Config {
if (window.VITEST) {
return {
nodes: {
fallbackPublicExplorer: "https://app.radicle.xyz/nodes/$host/$rid$path",
apiVersion: "0.1.0",
defaultHttpdHostname: "127.0.0.1",
defaultHttpdPort: 8081,
defaultLocalHttpdPort: 8081,
defaultHttpdScheme: "http",
defaultNodePort: 8776,
pinned: [],
},
supportWebsite: "https://radicle.zulipchat.com",
fallbackPreferredSeed: {
hostname: "seed.radicle.garden",
port: 443,
scheme: "https",
},
};
} else if (window.PLAYWRIGHT) {
return window.APP_CONFIG;
} else {
// In dev and production environments we use data from config.json.
return configJson;
}
}
export const config = getConfig();