From 73b2c9777d53720324ec7e63bb95727590ef4c11 Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Sat, 9 Aug 2025 14:11:04 +0800 Subject: [PATCH] Make config parameter optional in Google Translate service Updated the translateWithGoogle function to accept an optional config parameter and handle missing clientIP values gracefully. This improves flexibility and prevents errors when config or its properties are undefined. --- src/lib/services/googleTranslate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/services/googleTranslate.ts b/src/lib/services/googleTranslate.ts index ef00b53..db0f88c 100644 --- a/src/lib/services/googleTranslate.ts +++ b/src/lib/services/googleTranslate.ts @@ -19,7 +19,7 @@ import { */ export async function translateWithGoogle( params: RequestParams, - config: Config & { env: any; clientIP: string } + config?: Config & { env?: any; clientIP?: string } ): Promise { try { const { text, source_lang, target_lang } = params; @@ -88,7 +88,7 @@ export async function translateWithGoogle( const errorResponse = createErrorResponse(error, { endpoint: "/google", - clientIP: config.clientIP, + clientIP: config?.clientIP || "unknown", }); return errorResponse.response;