mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-14 11:49:16 +00:00
Update src/app/api/categories/route.ts with necessary modifications
This commit is contained in:
parent
e5c7df88a6
commit
e63236b33c
@ -4,31 +4,28 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export const dynamic = "force-static";
|
export const dynamic = "force-static";
|
||||||
|
|
||||||
const fetchCategories = async (): Category[] => {
|
const fetchCategories = async (): Promise<Category[]> => {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://raw.githubusercontent.com/community-scripts/${basePath}/refs/heads/main/json/metadata.json`,
|
`https://raw.githubusercontent.com/community-scripts/${basePath}/refs/heads/main/json/metadata.json`,
|
||||||
);
|
);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data.categories;
|
return data.categories;
|
||||||
}
|
};
|
||||||
|
|
||||||
const fetchScripts = async (): Script[] => {
|
const fetchScripts = async (): Promise<Script[]> => {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://api.github.com/repos/community-scripts/${basePath}/contents/json`,
|
`https://api.github.com/repos/community-scripts/${basePath}/contents/json`,
|
||||||
);
|
);
|
||||||
const files = await response.json();
|
const files: { download_url: string }[] = await response.json();
|
||||||
const scripts = files.map(async (file) => {
|
const scripts = await Promise.all(
|
||||||
const response = await fetch(file.download_url);
|
files.map(async (file) => {
|
||||||
const script = await response.json();
|
const response = await fetch(file.download_url);
|
||||||
return script
|
const script = await response.json();
|
||||||
})
|
return script as Script;
|
||||||
for (const file of files) {
|
})
|
||||||
const response = await fetch(file.download_url);
|
);
|
||||||
const script = await response.json();
|
|
||||||
scripts.push(script);
|
|
||||||
}
|
|
||||||
return scripts;
|
return scripts;
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user