Files
swingmusic-extended/src/config.ts
T
geoffrey45 94eb198e47 major redesign and refactor
+ centralized urls
+ reduce max app width
+ bump up header height to 23rem
2022-09-15 12:36:30 +03:00

86 lines
1.6 KiB
TypeScript

export interface D<T = string> {
[key: string]: T;
}
const domains: D = {
local: "http://localhost:",
remote: "http://10.5.86.154:",
};
const ports = {
api: 1970,
images: 1971,
};
const imageRoutes = {
thumb: "/t/",
artist: "/a/",
playlist: "/p/",
raw: "/raw/",
};
let mode: string = "remote";
function toggleMode() {
mode = mode === "local" ? "remote" : "local";
}
function getDomain() {
return domains[mode];
}
const baseImgUrl = getDomain() + ports.images;
const baseApiUrl = getDomain() + ports.api;
const paths = {
api: {
album: baseApiUrl + "/album",
get albumartists() {
return this.album + "/artists";
},
get albumbio() {
return this.album + "/bio";
},
folder: baseApiUrl + "/folder",
playlist: {
base: baseApiUrl + "/playlist",
get new() {
return this.base + "/new";
},
get all() {
return this.base + "s";
},
get artists() {
return this.base + "/artists";
},
},
search: {
base: baseApiUrl + "/search",
get tracks() {
return this.base + "/tracks?q=";
},
get albums() {
return this.base + "/albums?q=";
},
get artists() {
return this.base + "/artists?q=";
},
get load() {
return this.base + "/loadmore";
},
},
files: baseApiUrl + "/file",
},
images: {
thumb: baseImgUrl + imageRoutes.thumb,
artist: baseImgUrl + imageRoutes.artist,
playlist: baseImgUrl + imageRoutes.playlist,
raw: baseImgUrl + imageRoutes.raw,
},
};
export { paths, toggleMode };
// TODO: Add setting to toggle between extending to edges or not