From f27e3dd3cdfcca7996553a74a695a538acd9353f Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Fri, 11 Aug 2023 06:42:58 -0500 Subject: [PATCH] changed to simple response. --- functions/api/voice/token.ts | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/functions/api/voice/token.ts b/functions/api/voice/token.ts index 605ea0e..75bce88 100644 --- a/functions/api/voice/token.ts +++ b/functions/api/voice/token.ts @@ -1,34 +1,11 @@ interface Env { VOICE_TOKEN: string; } -export const onRequest: PagesFunction = async (context) => { - try { - console.log('start'); - async function gatherResponse(response: Response) { - const {headers} = response; - const contentType = headers.get('content-type') || ''; - if (contentType.includes('application/json')) { - return await response.text(); - } else if (contentType.includes('application/text')) { - return await response.text(); - } else if (contentType.includes('text/html')) { - return await response.text(); - } else { - return await response.text(); - } - } - - const res = await fetch('https://api.assemblyai.com/v2/realtime/token', - { - method: 'POST', - body: JSON.stringify({expires_in: 3600}), - headers: {authorization: context.env.VOICE_TOKEN} - }); - const results = await gatherResponse(res); - - return new Response(results, {status: 200}); - } catch (error) { - return new Response(error.message, {status: 500}); +const handler: ExportedHandler = { + async fetch(request, context) { + console.log(context.VOICE_TOKEN); + return new Response('Hello World 2!'); } } +export default handler; \ No newline at end of file