Skip to content

fix(export): align local API routes and config cleanup#4355

Merged
ravern merged 4 commits intomasterfrom
fix/export-local-api-routes
Mar 10, 2026
Merged

fix(export): align local API routes and config cleanup#4355
ravern merged 4 commits intomasterfrom
fix/export-local-api-routes

Conversation

@yangshun
Copy link
Copy Markdown
Member

@yangshun yangshun commented Mar 9, 2026

Summary

  • align the local export server routes with the deployed /api/export/* paths used by the website client and docs
  • add a simple export/public/test.html page for manually exercising local image and PDF exports
  • clean up export config/docs by removing the stale CHROME_EXECUTABLE config entry, simplifying .env.example, and updating the local export comments
  • remove the unused PM2-specific deploy path by deleting export/ecosystem.config.js, dropping the deploy script, and making pnpm start run the built server directly

Test plan

  • pnpm --dir export typecheck
  • pnpm --dir export build

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
nusmods-export Ignored Ignored Preview Mar 10, 2026 8:59am
nusmods-website Ignored Ignored Preview Mar 10, 2026 8:59am

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 9, 2026

Confidence Score: 4/5

  • This PR is safe to merge; the route alignment is correct and the config cleanup is intentional, with only a minor unused import to address.
  • All functional changes are well-scoped and correct. The one minor issue is an unused import config left in chrome-executable.ts after removing the config.chromeExecutable reference — it won't cause a build failure (tsconfig does not set noUnusedLocals) but is dead code.
  • export/src/chrome-executable.ts — unused config import should be removed

Important Files Changed

Filename Overview
export/src/app.ts Route paths updated from /image and /pdf to /api/export/image and /api/export/pdf to align with the deployed server and client. No logic changes.
export/src/chrome-executable.ts Removed config.chromeExecutable early-return path and updated the final error message. Leaves behind an unused import config from './config' that should be cleaned up.
export/src/config.ts Removed chromeExecutable config entry (CHROME_EXECUTABLE env var) as part of the stale config cleanup. No issues.
export/.env.example Removed stale CHROME_EXECUTABLE and MODULE_DATA env var examples; updated comment to reference config.ts; cleared the placeholder Sentry DSN. Clean and accurate.
export/public/test.html New static test page providing quick links to exercise local image and PDF export endpoints. Straightforward and useful for manual testing.
website/src/apis/export.ts Comment updated to reference the new local URL pattern (http://localhost:3000/api/export). No logic changes; baseUrl already pointed at the correct production path.

Sequence Diagram

sequenceDiagram
    participant C as Client (website)
    participant E as Export Server (Koa)
    participant P as Puppeteer/Chrome

    Note over C,E: Before this PR — routes were /image and /pdf
    Note over C,E: After this PR — routes are /api/export/image and /api/export/pdf

    C->>E: GET /api/export/image?data=...&pixelRatio=...
    E->>E: data.parseExportData (middleware)
    E->>P: render.openPage — launch/reuse browser, open timetable page
    P-->>E: page ready
    E->>P: render.image(page, data, options)
    P-->>E: PNG buffer
    E-->>C: 200 OK — My Timetable.png

    C->>E: GET /api/export/pdf?data=...
    E->>E: data.parseExportData (middleware)
    E->>P: render.openPage — reuse browser page
    P-->>E: page ready
    E->>P: render.pdf(page, data)
    P-->>E: PDF buffer
    E-->>C: 200 OK — My Timetable.pdf
Loading

Comments Outside Diff (1)

  1. export/src/chrome-executable.ts, line 3 (link)

    Unused import left behind

    After removing the config.chromeExecutable check, config is no longer referenced anywhere in this file. The import should be removed to avoid dead code.

Last reviewed commit: ea74a6e

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.67%. Comparing base (988c6fd) to head (59d3b68).
⚠️ Report is 209 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4355      +/-   ##
==========================================
+ Coverage   54.52%   56.67%   +2.15%     
==========================================
  Files         274      308      +34     
  Lines        6076     6964     +888     
  Branches     1455     1682     +227     
==========================================
+ Hits         3313     3947     +634     
- Misses       2763     3017     +254     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread export/public/test.html
@@ -0,0 +1,16 @@
<!doctype html>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will make it easier to test the deployment, just go to /test.html.

I'll look into adding some unit/E2E tests, but Vercel has a different deployment flow so this is still needed for testing on Vercel.

Comment thread export/src/app.ts

router
.get('/image', async (ctx) => {
.get('/api/export/image', async (ctx) => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the routes on Koa vs Vercel.

Comment thread export/ecosystem.config.js Outdated
@yangshun yangshun requested review from leslieyip02 and ravern March 9, 2026 07:14
ravern and others added 2 commits March 10, 2026 16:49
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Copy link
Copy Markdown
Member

@ravern ravern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ravern ravern merged commit 86bb49b into master Mar 10, 2026
6 checks passed
@ravern ravern deleted the fix/export-local-api-routes branch March 10, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants