mirror of
https://github.com/Radiquum/YAMPD.git
synced 2025-05-20 15:49:34 +05:00
feat: add modrinth mod
This commit is contained in:
parent
237ce9879d
commit
e453f336a8
8 changed files with 398 additions and 21 deletions
|
@ -1,17 +1,22 @@
|
|||
const API = process.env.NEXT_PUBLIC_API_URL || "/api";
|
||||
|
||||
type _PACK_ENDPOINT = {
|
||||
getPack: string;
|
||||
getPackImage: string;
|
||||
getPack: string;
|
||||
getPackImage: string;
|
||||
editPackImage: string;
|
||||
};
|
||||
|
||||
type _PACKS_ENDPOINT = {
|
||||
getPacks: string;
|
||||
getPacks: string;
|
||||
createPack: string;
|
||||
deletePack: string;
|
||||
};
|
||||
|
||||
type _MOD_ENDPOINT = {
|
||||
addMod: string;
|
||||
deleteMod: string;
|
||||
};
|
||||
|
||||
export const PACK_ENDPOINT = (endpoint: keyof _PACK_ENDPOINT, id: string) => {
|
||||
if (!id) {
|
||||
console.error(`ENDPOINT "${endpoint}" REQUIRES A PACK ID`);
|
||||
|
@ -19,8 +24,8 @@ export const PACK_ENDPOINT = (endpoint: keyof _PACK_ENDPOINT, id: string) => {
|
|||
}
|
||||
|
||||
const _endpoints = {
|
||||
getPack: `${API}/pack/${id}`,
|
||||
getPackImage: `${API}/pack/${id}/image`,
|
||||
getPack: `${API}/pack/${id}`,
|
||||
getPackImage: `${API}/pack/${id}/image`,
|
||||
editPackImage: `${API}/pack/${id}/image/edit`,
|
||||
};
|
||||
return _endpoints[endpoint];
|
||||
|
@ -37,9 +42,32 @@ export const PACKS_ENDPOINT = (
|
|||
}
|
||||
|
||||
const _endpoints = {
|
||||
getPacks: `${API}/packs/all`,
|
||||
getPacks: `${API}/packs/all`,
|
||||
createPack: `${API}/packs/new`,
|
||||
deletePack: `${API}/packs/${id}/delete`,
|
||||
};
|
||||
return _endpoints[endpoint];
|
||||
};
|
||||
|
||||
export const MOD_ENDPOINT = (
|
||||
endpoint: keyof _MOD_ENDPOINT,
|
||||
id: string,
|
||||
slug?: string | null
|
||||
) => {
|
||||
if (!id) {
|
||||
console.error(`ENDPOINT "${endpoint}" REQUIRES A PACK ID`);
|
||||
return "";
|
||||
}
|
||||
|
||||
const requireSlug: string[] = ["deleteMod"];
|
||||
if (requireSlug.includes(endpoint) && !slug) {
|
||||
console.error(`ENDPOINT "${endpoint}" REQUIRES A MOD SLUG`);
|
||||
return "";
|
||||
}
|
||||
|
||||
const _endpoints = {
|
||||
addMod: `${API}/pack/${id}/mod/add`,
|
||||
deleteMod: `${API}/pack/${id}/mod/${slug}/delete`,
|
||||
};
|
||||
return _endpoints[endpoint];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue