Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Suggest source for transcription #34

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.0",
"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