swingmusic/src/config.ts
geoffrey45 4a49d48011 show albums from artist at the bottom of album page
+ add a testing genres strip in album page
+ misc refactors
2023-01-13 18:13:49 +03:00

92 lines
1.8 KiB
TypeScript

// "local" | "remote"
let mode = "local";
export interface D<T = string> {
[key: string]: T;
}
const domains: D = {
local: "http://localhost:",
remote: "http://10.16.22.240:",
};
const ports = {
api: 1970,
images: 1971,
};
const imageRoutes = {
thumb: {
large: "/t/",
small: "/t/s/",
},
artist: "/a/",
playlist: "/p/",
raw: "/raw/",
};
function toggleMode() {
mode = mode === "local" ? "remote" : "local";
}
const domain = () => domains[mode];
const baseImgUrl = domain() + ports.images;
const baseApiUrl = domain() + ports.api;
const paths = {
api: {
album: baseApiUrl + "/album",
get albumartists() {
return this.album + "/artists";
},
get albumbio() {
return this.album + "/bio";
},
get albumsByArtistUrl(){
return this.album + "/from-artist"
},
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: {
small: baseImgUrl + imageRoutes.thumb.small,
large: baseImgUrl + imageRoutes.thumb.large,
},
artist: baseImgUrl + imageRoutes.artist,
playlist: baseImgUrl + imageRoutes.playlist,
raw: baseImgUrl + imageRoutes.raw,
},
};
export { paths, toggleMode };