Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(remix-serve): allow passing getLoadContext to createApp #3296

Closed

Conversation

TillaTheHun0
Copy link

This PR allows passing getLoadContext into @remix-run/express from @remix-run/serve. It doesn't change current functionality, just exposes getLoadContext on @remix-run/serve

The use case is that as a developer, I want to programmatically invoke createApp, to get the built express app, and then manually start the server, or even modify the app further ie. more routes, middleware, etc. Allowing to pass getLoadContext seemed kosher to me.

This of course would not be available via the remix serve CLI.

An alternative approach would be for a developer to reimplement what @remix-run/serve is doing, if they want to provide a getLoadContext. Though I would rebut that since @remix-run/serve interfaces with @remix-run/dev and wires all of the Remix build outputs into express for the developer, I think exposing here would help avoid potential "issue bloat" from folks implementing a million different ways. They could just use @mirex-run/serve.

  • Docs
  • Tests

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented May 24, 2022

Hi @TillaTheHun0,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented May 24, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@MichaelDeBoey MichaelDeBoey changed the title feat(remix-serve): allow passing getLoadContext for programattically starting server feat(remix-serve): allow passing getLoadContext to createApp May 24, 2022
@kiliman
Copy link
Collaborator

kiliman commented May 24, 2022

Hmm.. it seems like if you need to use context, it would be simpler to just use the Express adapter. Remix App Server is meant to be a batteries-include no-config server.

You can eject from RAS to Express using this script: https://github.com/kiliman/rmx-cli#eject-ras

@ZipBrandon
Copy link

Is this accomplishing the same objective as #2045 and #1606 ? If so, then #2045 is the most conditioned PR to merge. Hopefully that will get merged shortly now that Remix Conf is in the rearview.

@chaance
Copy link
Collaborator

chaance commented Jan 24, 2023

Echoing @kiliman's sentiments here, based on your use-case this is exactly why we have our lower-level Express adapter. remix-serve is designed to get you up-and-running, but it isn't meant to satisfy the need for load context and high levels of customization. I generally expect that most apps will ultimately end up with the need to call createRequestHandler in their own server, and it sounds like you're already there 🙂

@chaance chaance closed this Jan 24, 2023
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.

5 participants