Repository navigation
Add HTTP caching, timetable slot flags, and NEIS schedule integration - #17
Merged
Merged
Conversation
Every 200 JSON response from /timetable, /lunch, /schedule, /school and /classes now carries a strong ETag (SHA-256 of the serialised body). A matching If-None-Match (weak comparison, lists and * supported) gets a 304 with an empty body. Cache-Control keeps max-age=0 and adds per-route s-maxage so the Vercel CDN can absorb repeated polls; 404 NEIS_DATA_NOT_FOUND is cacheable for an hour and every other error is no-store. Status codes and bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
/timetable now returns week_start, the YYYYMMDD Monday of the week the response describes, computed in Asia/Seoul so the UTC server agrees with Korean clients. Clients that cache week=1 can tell when that cached "next week" has become this week. Reuses the client's weekYmdRange, now exported from @timeforschool/client/timetable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
Each /timetable slot gains two booleans, appended after `original`: - cancelled: replaced is true and subject is empty (exam-day lessons that were dropped; `original` keeps the lesson) - makeup: subject starts with "[보강]" subject, teacher, replaced and original are unchanged, so existing clients that ignore unknown keys see the same data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
/timetable now returns `days`, index-aligned with `timetable`:
{ date, closed, events }. It comes from SchoolSchedule for Mon–Sat of
week_start, started before the timetable fetch so both upstream calls
overlap, and reuses the route's NeisClient.
- Only rows whose *_GRADE_EVENT_YN for the requested grade is "Y" count.
- closed: a kept row is 공휴일 or 휴업일. events: kept EVENT_NMs,
without 토요휴업일.
- An empty week returns closed:false / events:[] for every day.
- A failed or slow (>1s after the timetable is ready) schedule lookup
omits `days`; the timetable still answers 200.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
GET /schedule accepts an optional grade (1–6). When set, only rows whose matching *_GRADE_EVENT_YN is "Y" are returned, in their raw NEIS shape. An empty result after filtering is still 404 NEIS_DATA_NOT_FOUND (with `grade` added to its details). Without grade, behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
- day_time: the example was "09:00"; the real format is
"<period>(HH:MM)" (e.g. "1(08:10)"), start times only, and the array
is empty when Comcigan has none.
- original: documented as {period, subject, teacher} or null, with the
exam-day cancelled lesson as an example. Validation is unchanged.
- Timetable example now shows a cancelled and a make-up period.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds HTTP caching with ETags, enriches timetable periods with
cancelledandmakeupflags, integrates NEIS school calendar events into the/timetableresponse, and introduces helper utilities for working with Korean school schedules.Key Changes
HTTP Caching (
src/http/cache.ts,src/test/http-cache.ts)If-None-Matchmatching with weak comparison supportCache-Controlheaders with CDN-friendlys-maxagevalues:/timetable: 5 minutes/lunchand/schedule: 6 hours/schooland/classes: 1 day404 NEIS_DATA_NOT_FOUND: 1 hour (cacheable error)no-storehttpCache()Elysia hook for automatic 304 Not Modified responses when ETags matchTimetable Enhancements (
src/services/timetable-extras.ts,src/test/timetable-extras.ts)cancelled(replaced with empty subject) andmakeup(subject starts with[보강]) boolean flags to timetable periodsweekStartYmd(),addDaysYmd(),kstYmd(), andweekYmdRange()for KST-aware date calculationsappliesToGrade()andfilterScheduleByGrade()to filter NEIS SchoolSchedule rows by grade (1–6)mapScheduleToDays()to convert NEIS rows into day objects withclosedstatus and event listsfetchWeekSchedule()to fetch Mon–Sat calendar events with graceful error handling (empty array on no data, undefined on network failure)withDeadline()for timeout-based promise resolution/timetableResponse Updatesweek_startfield (YYYYMMDD Monday in KST) to responsesdaysarray (index-aligned with timetable) containing:date: YYYYMMDDclosed: true for holidays/closuresevents: grade-filtered NEIS calendar event namesday_timeformat from"HH:MM"to"<period>(HH:MM)"(e.g.,"1(08:10)")cancelledandmakeupflags/scheduleEndpoint Enhancementgradequery parameter (1–6) to filter SchoolSchedule rows by gradeSchema & Documentation Updates
TimetablePeriodSchemawith newcancelledandmakeupfieldsTimetableDaySchemafor the newdaysarrayTimetableResponseSchemawithweek_startanddaysIntegration (
src/app.ts)httpCache()hook to/schooland/classesendpoints/timetablehandler with 1-second grace periodNotable Implementation Details
토요휴업일(Saturday holiday) is filtered out fromdaysto avoid redundant Saturday entrieseventsarraydaysrather thanhttps://claude.ai/code/session_01DvQgaoFCY6wDChdDYQbV8D