Skip to content

Commit

Permalink
Merge pull request #232 from FalkorDB/add-tip
Browse files Browse the repository at this point in the history
Fix #218 add tip
  • Loading branch information
AviAvni authored Nov 21, 2024
2 parents 9e01868 + 98c709e commit 83f9167
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 828 deletions.
21 changes: 0 additions & 21 deletions app/api/repo/[graph]/[node]/route.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest, { params }: { params: { graph: string, node: string } }) {

const nodeId = parseInt(params.node);
const graphId = params.graph;
try {

const result = await fetch(`${process.env.BACKEND_URL}/get_neighbors?repo=${graphId}&node_id=${nodeId}`, {
method: 'GET',
headers: {
"Authorization": process.env.SECRET_TOKEN!,
}
})

const json = await result.json()

return NextResponse.json({ result: json }, { status: 200 })
} catch (err) {
return NextResponse.json({ massage: (err as Error).message }, { status: 400 })
}
}

export async function POST(request: NextRequest, { params }: { params: { graph: string, node: string } }) {

const nodeId = params.node;
Expand Down
24 changes: 24 additions & 0 deletions app/api/repo/[graph]/neighbors/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from "next/server";

export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {

const { nodeIds } = await request.json();
const graphId = params.graph;
try {

const result = await fetch(`${process.env.BACKEND_URL}/get_neighbors`, {
method: 'POST',
body: JSON.stringify({ node_ids: nodeIds, repo: graphId }),
headers: {
"Content-Type": 'application/json',
"Authorization": process.env.SECRET_TOKEN!,
}
})

const json = await result.json()

return NextResponse.json({ result: json }, { status: 200 })
} catch (err) {
return NextResponse.json({ massage: (err as Error).message }, { status: 400 })
}
}
Loading

0 comments on commit 83f9167

Please sign in to comment.