Skip to content

Conversation

@vonuyvicoo
Copy link

@vonuyvicoo vonuyvicoo commented Oct 15, 2025

What changed

  • Centralized context creation: Moved createContext into functions/helpers/context.ts for reuse across routes and middleware.
  • Centralized route wrappers: Extracted wrapHandler, wrapHandlerWithAuth, wrapHandlerWithConditionalAuth, and wrapHandlerWithOwnership into functions/helpers/wrappers.ts, consolidating auth and ownership checks.
  • Simplified functions/index.ts: Replaced inline wrapper and context implementations with imports from the helpers, keeping the router configuration focused and readable.
  • Removed ad hoc matching: By standardizing wrapper usage, we eliminated scattered, conditional, and regex-like handling in route definitions, making behavior consistent and easier to maintain.

Impact

  • Cleaner routing layer: Route files now declare intent (public/protected/ownership) without duplicating boilerplate.
  • Consistent middleware behavior: Auth and ownership checks are applied uniformly via wrappers.
  • Easier reuse and testing: Shared helpers can be imported across future handlers without duplication.

Link to Issue

#18

@jasontorres
Copy link
Collaborator

Lovely work. I love it. Approving it and will wait for another team member to review! @angelofallars.

@jasontorres
Copy link
Collaborator

@vonuyvicoo can you join the discord chat as well? there's a project called Petitions by BetterGov.ph in there

@vonuyvicoo
Copy link
Author

Sure! I'll join :)

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