Skip to content

Commit 18483d3

Browse files
fix(translate): return string translation stub instead of post payload
Replace the stub that returned the whole post object as "translated" content (which Redis stored as the literal "[object Object]"). translate() is now async, returns [isEnglish, translatedText] with a hardcoded string, and documents that the second value must stay a string for correct hash storage.
1 parent 96b8426 commit 18483d3

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/translate/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44

55
const translatorApi = module.exports;
66

7-
translatorApi.translate = function (postData) {
8-
return ['is_english',postData];
7+
/**
8+
* @returns {Promise<[boolean, string]>}
9+
* Second value must always be a string — Redis hashes persist fields with String(value), so objects become "[object Object]".
10+
*/
11+
translatorApi.translate = async function (postData) {
12+
// Stub: real implementation would call a translation API and assign a string to translatedContent.
13+
const isEnglish = false;
14+
const translatedContent = 'This is a hardcoded English translation returned from the translator API.';
15+
return [isEnglish, translatedContent];
916
};
1017

1118
// translatorApi.translate = async function (postData) {
@@ -14,4 +21,4 @@ translatorApi.translate = function (postData) {
1421
// const response = await fetch(TRANSLATOR_API+'/?content='+postData.content);
1522
// const data = await response.json();
1623
// return ['is_english','translated_content'];
17-
// };
24+
// };

0 commit comments

Comments
 (0)