nusmods / export
AGENTS.md690 starsChanged 6 years agoMITView on GitHub
Timetable → PNG/PDF export service. Koa server (src/index.ts, src/app.ts) locally; on Vercel the entry points are api/export/image.ts and api/export/pdf.ts (15s max duration), which use src/render-serverless.ts and @sparticuz/chromium. The website serialises timetable state into a data query param. This service validates it (Joi, src/data.ts), opens a Puppeteer page with the website's timetable-only bundle (website/src/entry/export/), injects the state into Redux and screenshots or prints the page. The rendered UI therefore lives in website/, not here. Layout bugs in exports are usually fixed…
- Reads credentials
Files
export/
Timetable → PNG/PDF export service. Koa server (src/index.ts, src/app.ts) locally; on Vercel the entry points are api/export/image.ts and api/export/pdf.ts (15s max duration), which use src/render-serverless.ts and @sparticuz/chromium.
How it works
The website serialises timetable state into a data query param. This service validates it (Joi, src/data.ts), opens a Puppeteer page with the website's timetable-only bundle (website/src/entry/export/), injects the state into Redux and screenshots or prints the page. The rendered UI therefore lives in website/, not here. Layout bugs in exports are usually fixed in website/src/entry/export or the timetable components.
Local dev
cp .env.example .env # ACADEMIC_YEAR=YYYY-YYYY is required; PAGE defaults to production nusmods.com/timetable-only
pnpm --dir ../website start:export # optional: serve local timetable-only page on :8081, then set PAGE=http://localhost:8081
pnpm dev # tsc --watch + nodemon on :3000
pnpm devtools # same with a visible browser; PDF export does not work in this modeExample URLs are in README.md. GET /debug returns the HTML Puppeteer renders.
Notes
- There are no unit tests; CI only runs
pnpm lint,pnpm typecheckandpnpm build. Verify changes manually with the README's example URLs. PAGEis either a URL (dev, loaded withgoto) or a local file path (prod, loaded withsetContent). Behaviour differs, so test the mode you changed.MODULE_DATAunset means module data is fetched from the NUSMods API. In production, a set path must exist.ExportDatainsrc/types.tsis a hand-copied duplicate ofwebsite/src/types/export.ts. Change both together, along with the URL builder inwebsite/src/apis/export.ts.
In this repository2 other files it gives its agents.
- AGENTS.mdAGENTS.md
- website/AGENTS.mdAGENTS.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

