Open-Generative-AI/app/api
Anuragp22 2e2664bf78 feat(batch): degrade to local-only uploads when MuAPI is unreachable
Until the team has MuAPI credits we cannot upload trainer/studio
images to MuAPI's CDN, which previously caused POST /api/trainers
to fail outright with a 502. Now the route always saves a local
copy first and only attempts MuAPI as an enhancement.

Behaviour change
----------------
- Trainer/studio rows are created even without a MuAPI key. The
  imageUrl points at a new /api/uploads/<kind>/<filename> route
  that streams the file out of /data/uploads/.
- If MuAPI is reachable (key present + upload succeeds) we still
  prefer its CDN URL, identical to before for the happy-path team
  who already has credits.
- The slice-4 worker will need to detect local-only imageUrls and
  re-upload to MuAPI at job-submission time. Tracked, not in this PR.

Files
-----
- lib/localUploadStore.js: add readLocal() and publicUrlFor() so the
  serving route and the upload route share the same naming scheme.
  Path-traversal guard on the read side (no '/', '..', '\' in name).
- app/api/uploads/[kind]/[name]/route.js: GET serves the bytes with
  the right Content-Type and a 1h private cache header. Whitelists
  kind to {trainers, studios}.
- app/api/trainers/route.js, app/api/studios/route.js: rewritten so
  the create flow is "DB row -> local backup -> optional MuAPI". On
  total failure (both MuAPI and local) we delete the row to avoid
  orphans. The response now also surfaces a `muapiNote` string so
  the UI can hint at "no credits yet".
2026-04-23 08:34:57 +05:30
..
agents/[[...path]] feat: integrate AI agent studio with minimal UI and upgrade Tailwind v4 2026-04-22 15:22:26 +05:30
api/v1/[[...path]] feat: integrate AI agent studio with minimal UI and upgrade Tailwind v4 2026-04-22 15:22:26 +05:30
app/[[...path]] feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30
batches feat(batch): New Batch wizard, CSV parser, and batch list 2026-04-23 08:01:15 +05:30
studios feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
trainers feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
upload-binary feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30
uploads/[kind]/[name] feat(batch): degrade to local-only uploads when MuAPI is unreachable 2026-04-23 08:34:57 +05:30
workflow/[[...path]] feat: implement workflow identity persistence, unify api auth, and upgrade tailwind to v4 2026-04-21 19:38:34 +05:30