Dorms API route #123

Closed
opened 2026-10-26 16:56:19 +00:00 by gostmeaper · 0 comments
Member

Overall Objective

Serve dorm data from the backend so the frontend stops shipping 26 buildings of JSON in its bundle and so building data can be corrected without a frontend release.

This is also our first public route. Dorm data is not user-specific, and guests browse buildings today via the "Continue as guest" path on the launch page, so this must work with no session cookie at all.

Requires Seeding Issue to be finished or picked up concurrently.

Suggested Approach

  1. Create apps/backend/src/routes/dorms.ts with:
    • GET /api/dorms, list all dorms.
    • GET /api/dorms/:slug, one dorm, with a typed 404 when the slug is unknown.
  2. Use .use(dbPlugin) and not .use(sessionAuth), with no if (!user) check. apps/backend/src/routes/health.ts is the unauthenticated shape; preferences.ts is the authenticated one.
  3. Register it in apps/backend/src/index.ts alongside .use(healthRoute).
  4. Think about payload size before you ship. Twenty-six dorms with full photo galleries and floor-plan arrays is a lot for a list endpoint the home page hits on every load. Consider a leaner list shape with the full record on the detail endpoint. Whichever you choose, write the reasoning in the PR, because later issues will need that reasoning.
  5. Do not build filtering here. scoring.ts filters 26 records in the browser and that is fine. We'll move it later maybe
  6. Test at http://localhost:3001/api/docs, then test again in a private window with no session cookie.

Help & Resources

### Overall Objective Serve dorm data from the backend so the frontend stops shipping 26 buildings of JSON in its bundle and so building data can be corrected without a frontend release. This is also our first public route. Dorm data is not user-specific, and guests browse buildings today via the "Continue as guest" path on the launch page, so this must work with no session cookie at all. Requires Seeding Issue to be finished or picked up concurrently. ### Suggested Approach 1. Create `apps/backend/src/routes/dorms.ts` with: - `GET /api/dorms`, list all dorms. - `GET /api/dorms/:slug`, one dorm, with a typed 404 when the slug is unknown. 2. Use `.use(dbPlugin)` and not `.use(sessionAuth)`, with no `if (!user)` check. `apps/backend/src/routes/health.ts` is the unauthenticated shape; `preferences.ts` is the authenticated one. 3. Register it in `apps/backend/src/index.ts` alongside `.use(healthRoute)`. 4. Think about payload size before you ship. Twenty-six dorms with full photo galleries and floor-plan arrays is a lot for a list endpoint the home page hits on every load. Consider a leaner list shape with the full record on the detail endpoint. Whichever you choose, write the reasoning in the PR, because later issues will need that reasoning. 5. Do not build filtering here. `scoring.ts` filters 26 records in the browser and that is fine. We'll move it later maybe 6. Test at `http://localhost:3001/api/docs`, then test again in a private window with no session cookie. ### Help & Resources - [README](../../ScottyLabs/housing/src/branch/main/README.md) - [Contributing Guidelines](../../ScottyLabs/housing/src/branch/main/docs/CONTRIBUTING.md) - [Elysia: path parameters](https://elysiajs.com/essential/route.html#path-type)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/housing#123
No description provided.