Conversation
|
Caution Review failedThe pull request is closed. WalkthroughcreateAccessToken was changed to return a plain token string (Promise); sendToIntegration now treats the token as a string, adds a check to throw a 500 if the token is missing, and continues to call the deliveries/create API using that token. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web-app/server/api/tilda/fila.post.ts (1)
152-160: Consider switching toawaitfor clearer error handling and typingRight now you return the fetch promise chain directly. That means:
- The local
try/catchinsendToIntegrationonly handles errors up tocreateAccessToken; failures fromfetch/res.json()are only caught by the outer event handler’stry/catch.- The return type of
sendToIntegrationis effectivelyany, which makes it harder to rely on the IIKO response shape elsewhere.You could make error handling and types clearer by using
awaitand (optionally) typing the response:async function sendToIntegration(data: TildaFilaBody) /* : Promise<unknown | IIKOCreateDeliveryResponse> */ { const logger = useLogger('api:tilda:fila') const { iiko } = useRuntimeConfig() try { const { token } = await createAccessToken() // ...build body as before... const res = await fetch(apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, }, body: JSON.stringify(body), }) const json = await res.json() return json } catch (error) { logger.error(error) // optionally: rethrow if you want caller to see integration failures // throw error } }This keeps all network/JSON errors within the same
try/catchand makes the control flow easier to reason about, while preserving the new “parsed JSON” behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web-app/server/api/tilda/fila.post.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: build
🔇 Additional comments (1)
apps/web-app/server/api/tilda/fila.post.ts (1)
152-160: Return type change to parsed JSON looks goodReturning
await fetch(...).then((res) => res.json())fromsendToIntegrationmatches the PR goal:resultin the handler is now the actual IIKO JSON payload rather than aResponseobject, so the log on Line 14 becomes much more informative. SincesendToIntegrationis only used in this file and the caller only logsresult, this behavior change is safe.
|



Summary by cubic
Parse the iiko integration response to JSON so sendToIntegration returns structured data instead of a raw Response. This fixes incorrect result handling in the Tilda Fila endpoint.
Written for commit 5f3f0cd. Summary will update automatically on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.