Add language endpoint to developer APIs (#41)

* Added languages endpoint and its tests
This commit is contained in:
David
2021-08-30 21:35:22 +02:00
committed by GitHub
parent 1b6c324560
commit 870ec2db64
11 changed files with 360 additions and 74 deletions

View File

@@ -7,8 +7,9 @@ export async function googleScrape(
target: string,
query: string
): Promise<{
translationRes?: string,
errorMsg?: string
translationRes: string
} | {
errorMsg: string
}> {
const parsed = replaceBoth("mapping", { source, target });
const res = await fetch(
@@ -56,10 +57,7 @@ export function extractSlug(slug: string[]): {
}
}
export async function textToSpeechScrape(lang: string, text?: string) {
if (!text)
return null;
export async function textToSpeechScrape(lang: string, text: string) {
const { target: parsedLang } = replaceBoth("mapping", { source: "", target: lang });
const lastSpace = text.lastIndexOf(" ", 200);