Skip to content

Feat/tos#777

Open
jona159 wants to merge 37 commits intodevfrom
feat/tos
Open

Feat/tos#777
jona159 wants to merge 37 commits intodevfrom
feat/tos

Conversation

@jona159
Copy link
Contributor

@jona159 jona159 commented Mar 3, 2026

Type of Change

  • Dependency upgrade
  • Bug fix (non-breaking change)
  • Breaking change
    • e.g. a fixed bug or new feature that may break something else
  • New feature
  • Code quality improvements
    • e.g. refactoring, documentation, tests, tooling, ...

Implementation

Checklist

  • I gave this pull request a meaningful title
  • My pull request is targeting the dev branch
  • I have added documentation to my code
  • I have deleted code that I have commented out

Additional Information

  • This PR closes #

import { getTosRequirementForUser } from "~/models/tos.server";
import { getUserId } from "~/utils/session.server";

function isAllowedUiPath(pathname: string) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why we couldn't handle both ui and server in one middleware?
They seem very related to each other and technically we are always handling just "requests", right?

I do understand the response types are different, but this way there also seems to be quite a bit of duplication?
Maybe I am just too picky though :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes i thought about it as well, i initially thought that maybe in a single file it could get a bit messy with potentially more branches over time, but thinking about it again i guess this would still be quite manageable. In terms of code duplication i think the way it is at the moment is still somewhat justifiable, but i think i could still add a small helper to further reduce it.

Copy link
Member

Choose a reason for hiding this comment

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

I am also thinking a bit about "mental load" here. People have to remember to put the right middleware for the right kind of route. It's not like its hugely complicated though, so keeping it separate is probably perfectly fine.

Having more time comparing the two, I am realizing where the differences are. It does make it more complicated to unify the two, so overall we would be trading that for complexity of the code.
I'd rather create a base class/ function for each type of route to make sure the right middleware is called automatically and people don't have to bear the mental load of differentiating ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The right middleware should already be called automatically due to where they are attached (ui middlware in root.tsx and api in routes.api). Is this what you meant?

@jona159 jona159 linked an issue Mar 4, 2026 that may be closed by this pull request
@jona159 jona159 marked this pull request as ready for review March 4, 2026 14:13
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.

terms of service checks

2 participants