-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Suggest source for transcription
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
Showing
6 changed files
with
260 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NEXT_PUBLIC_VERCEL_ENV = "" # development | staging | production | ||
REVIEW_APP_URL = "" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.