Skip to content

Commit c097713

Browse files
committed
changes to make code more resiliant
1 parent 7bbabf7 commit c097713

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/server.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ async function callBackendApi(method, endpoint, data, incomingAuthHeader) {
308308

309309
// Check if response is successful
310310
if (!response.ok) {
311-
console.log(
312-
`\x1b[31m✖ API request failed with status ${response.status}: ${responseText}\x1b[0m`
313-
);
314311
throw new Error(
315312
`API request failed with status ${response.status}: ${responseText}`
316313
);
@@ -554,7 +551,18 @@ async function getAiChanges({
554551
/**
555552
* Service: Get changes from backend (original endpoint)
556553
* @param {Object} params Request parameters
557-
* @returns {Promise<Object>} Backend response
554+
* @param {string} params.githubRepoName The GitHub repository name
555+
* @param {Array<Object>} params.fileChanges Array of file change objects to process. Each object represents changes for a single file.
556+
* @param {string} params.fileChanges[].encoded_location The encoded file location identifier used to determine which file to modify
557+
* @param {string} params.fileChanges[].file_content The current content of the file being modified
558+
* @param {Array<Object>} params.fileChanges[].style_changes Array of style-related changes to apply to the file. Each object contains styling modifications.
559+
* @param {Array<Object>} params.fileChanges[].text_changes Array of text-based changes to apply to the file. Each object contains:
560+
* @param {string} params.fileChanges[].text_changes[].old_text The original HTML/text content to be replaced (mapped from old_html)
561+
* @param {string} params.fileChanges[].text_changes[].new_text The new HTML/text content to replace with (mapped from new_html)
562+
* @param {string} [params.fileChanges[].text_changes[].encoded_location] The encoded location for this specific text change (inherited from parent change object)
563+
* @param {Array<Object>} [params.fileChanges[].text_changes[].style_changes] Any style changes associated with this text change (inherited from parent change object)
564+
* @param {string} [params.authHeader] The authorization header for backend API authentication (Bearer token)
565+
* @returns {Promise<Object>} Backend response containing the processed changes, typically with an 'updated_files' property mapping file paths to their new content
558566
*/
559567
async function getChanges({ githubRepoName, fileChanges, authHeader }) {
560568
console.log(
@@ -710,11 +718,6 @@ function createApp() {
710718
console.log(
711719
`\x1b[36mℹ Auth header received: ${authHeader ? "[PRESENT]" : "[MISSING]"}\x1b[0m`
712720
);
713-
if (authHeader) {
714-
console.log(
715-
`\x1b[36mℹ Auth header format: ${authHeader.substring(0, 20)}...\x1b[0m`
716-
);
717-
}
718721

719722
if (!Array.isArray(changes)) {
720723
return reply.code(400).send({

0 commit comments

Comments
 (0)