setup config to dynamically load base api url based

on the app running mode
This commit is contained in:
geoffrey45 2022-12-30 12:36:33 +03:00 committed by Mungai Njoroge
parent 31312d1754
commit 0b1ac6c02f

View File

@ -1,14 +1,8 @@
// "dev" | "prod"
let mode = "dev";
let development = import.meta.env.DEV;
const dev_url = "http://localhost:1970";
export interface D<T = string> {
[key: string]: T;
}
const domains: D = {
dev: "http://localhost:1970",
prod: "",
};
const baseApiUrl = development ? dev_url : "";
const baseImgUrl = baseApiUrl + "/img";
const imageRoutes = {
thumb: {
@ -23,15 +17,6 @@ const imageRoutes = {
raw: "/raw/",
};
function toggleMode() {
mode = mode === "dev" ? "prod" : "dev";
}
const domain = () => domains[mode];
const baseApiUrl = domain();
const baseImgUrl = baseApiUrl + "/img";
const paths = {
api: {
album: baseApiUrl + "/album",
@ -96,4 +81,4 @@ const paths = {
},
};
export { paths, toggleMode };
export { paths };