1- import { NextRequest , NextResponse } from "next/server" ;
1+ import { NextResponse } from "next/server" ;
2+ import { getEnvVariables } from "../utils" ;
23
34export async function GET ( ) {
45 try {
5- const result = await fetch ( `${ process . env . BACKEND_URL } /list_repos` , {
6+
7+ const { url, token } = getEnvVariables ( )
8+ const result = await fetch ( `${ url } /list_repos` , {
69 method : 'GET' ,
710 headers : {
8- "Authorization" : process . env . SECRET_TOKEN ! ,
9- }
11+ "Authorization" : token ,
12+ } ,
13+ cache : 'no-store'
1014 } )
1115
1216 if ( ! result . ok ) {
@@ -17,30 +21,40 @@ export async function GET() {
1721
1822 return NextResponse . json ( { result : repositories } , { status : 200 } )
1923 } catch ( err ) {
20- return NextResponse . json ( { message : ( err as Error ) . message } , { status : 400 } )
24+ console . error ( err )
25+ return NextResponse . json ( ( err as Error ) . message , { status : 400 } )
2126 }
2227}
2328
2429// export async function POST(request: NextRequest) {
30+
31+ // const repo_url = request.nextUrl.searchParams.get('url');
32+
33+ // try {
2534
26- // const url = request.nextUrl.searchParams.get('url');
35+ // if (!repo_url) {
36+ // throw new Error("URL parameter is missing");
37+ // }
38+
39+ // const { url, token } = getEnvVariables();
2740
28- // try {
29- // const result = await fetch(`${process.env.BEAKEND_URL}/process_repo`, {
41+ // const result = await fetch(`${url}/process_repo`, {
3042// method: 'POST',
31- // body: JSON.stringify({ repo_url: url , ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
43+ // body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
3244// headers: {
33- // "Authorization": process.env.SECRET_TOKEN! ,
45+ // "Authorization": token ,
3446// 'Content-Type': 'application/json'
35- // }
36- // })
47+ // },
48+ // cache: 'no-store'
49+ // });
3750
3851// if (!result.ok) {
39- // throw new Error(await result.text())
52+ // throw new Error(await result.text());
4053// }
4154
42- // return NextResponse.json({ message: "success" }, { status: 200 })
55+ // return NextResponse.json({ message: "success" }, { status: 200 });
4356// } catch (err) {
44- // return NextResponse.json({ message: (err as Error).message }, { status: 400 })
57+ // console.error(err)
58+ // return NextResponse.json((err as Error).message, { status: 400 });
4559// }
4660// }
0 commit comments