Skip to content

Conversation

aaronjordan
Copy link

@aaronjordan aaronjordan commented Oct 10, 2025

Drafted an idea I had watching the reveal livestream. This PR adds functional aliases for simple HTTP routes.

The route objects returned are super simple here, but providing them as functions to call would make the framework appear more consistent when defining a route using helpers. For instance, this would be an existing way to express some routes:

let routes = createRoutes({
  home:  { method: 'GET', pattern: '/' },
  books: resources('books'),
  profile: resource('profile'),
})

After this change, we would be able to use a consistent syntax for resources, formActions, and single-method routes.

let routes = createRoutes({
  home: get('/'),
  books: resources('books'),
  profile: resource('profile'),
})

I followed the resource.ts file to try to get the style right, please do advise on anything I could update!

@aaronjordan aaronjordan changed the title Add consistent alias functions for standard HTTP verb paths Add alias functions for standard HTTP verb paths Oct 10, 2025
@aaronjordan aaronjordan marked this pull request as ready for review October 10, 2025 21:11
- Export `InferRouteHandler` and `InferRequestHandler` types
- Re-export `FormDataParseError`, `FileUpload`, and `FileUploadHandler` from `@remix-run/form-data-parser`
- Fix an issue where per-route middleware was not being applied to a route handler nested inside a route map with its own middleware
- Adds functional aliases for routes that respond to a single HTTP verb
Copy link
Author

Choose a reason for hiding this comment

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

Would this actually go under a new 0.7.0 heading?

Copy link
Member

Choose a reason for hiding this comment

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

The CHANGELOG is updated when a release is created, this if merged would not be part of an already released version

@MichaelDeBoey MichaelDeBoey changed the title Add alias functions for standard HTTP verb paths feat(fetch-router): add alias functions for standard HTTP verb paths Oct 11, 2025
@mjackson
Copy link
Member

Thanks for the PR, @aaronjordan. I had the same thought. Could you please also add helpers for head, patch, and options? That would complete the set of supported request methods.

Also, I'd like to see a test along with this work that asserts the types are still what we expect them to be when these helpers are used in a larger route config.

As for the CHANGELOG, we include new changes under a ## Unreleased heading at the top of the CHANGELOG that gets swapped out with the release version when we cut a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants