Skip to content

Commit

Permalink
feat: Suggest source for transcription
Browse files Browse the repository at this point in the history
enables the related button and onSubmit calls
the intenal `/suggestSource` endpoint which
then calls the newly introduced `/suggestSource`
endpoint in the Review app which is then
responsible for all the related logic.
  • Loading branch information
kouloumos committed Sep 17, 2024
1 parent 9cbb382 commit 60e5013
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_VERCEL_ENV = "" # development | staging | production
REVIEW_APP_URL = ""
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@bitcoin-dev-project/bdp-ui": "^1.2.2",
"axios": "^1.7.7",
"contentlayer2": "^0.4.6",
"next": "14.2.4",
"next-contentlayer2": "^0.4.6",
Expand Down
42 changes: 42 additions & 0 deletions src/app/api/suggestSource/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { NextResponse } from "next/server";
import axios from "axios";

const REVIEW_APP_URL = process.env.REVIEW_APP_URL;

export async function POST(request: Request) {
try {
const { title, media, targetRepository } = await request.json();

const response = await axios.post(
`${REVIEW_APP_URL}/api/github/suggestSource`,
{
title,
media,
targetRepository,
},
{
headers: {
"Content-Type": "application/json",
},
}
);

return NextResponse.json(response.data);
} catch (error) {
console.error("Error suggesting source:", error);
if (axios.isAxiosError(error)) {
const errorMessage = error.response?.data?.message || error.message;
return NextResponse.json(
{ message: errorMessage },
{ status: error.response?.status || 500 }
);
} else {
return NextResponse.json(
{
message: "An unexpected error occurred while suggesting the source",
},
{ status: 500 }
);
}
}
}
Loading

0 comments on commit 60e5013

Please sign in to comment.