Skip to content

Commit ce44b16

Browse files
authored
debug (#226)
* Adjust the style of the Dependencies graph and add a new crates-all interface. * debug
1 parent e3cc04f commit ce44b16

File tree

2 files changed

+23
-1
lines changed
  • app
    • [nsfront]/[nsbehind]/[name]/[version]
    • api/crates/[nsfront]/[nsbehind]/[cratename]/[version]/unsafechecker

2 files changed

+23
-1
lines changed

app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const CratePage = () => {
156156
const [depCurrentPage, setDepCurrentPage] = useState(1);
157157
const [versions, setVersions] = useState<string[]>([]);
158158
const itemsPerPage = 1;
159-
const basePath = `/${params.nsfront}/${params.nsbehind}/${params.name}`;
159+
const basePath = `/${params.nsfront}/${params.nsbehind}/${params.name}/${params.version}`;
160160

161161
useEffect(() => {
162162
const fetchCrateData = async () => {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { NextRequest, NextResponse } from "next/server";
2+
type Params = Promise<{ nsfront: string, nsbehind: string, cratename: string, version: string }>
3+
export async function GET(req: NextRequest, props: { params: Params }) {
4+
try {
5+
const params = await props.params
6+
const { nsfront, nsbehind, cratename, version } = params;
7+
const endpoint = process.env.CRATES_PRO_INTERNAL_HOST;
8+
9+
const externalApiUrl = `${endpoint}/api/crates/${nsfront}/${nsbehind}/${cratename}/${version}/unsafechecker`;
10+
const externalRes = await fetch(externalApiUrl);
11+
if (!externalRes.ok) {
12+
throw new Error('Failed to fetch external data');
13+
}
14+
const externalData = await externalRes.json();
15+
console.log('External API Response:', externalData);
16+
return NextResponse.json(externalData);
17+
} catch (error) {
18+
console.error('Error:', error);
19+
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
20+
21+
}
22+
}

0 commit comments

Comments
 (0)