Dependency injection in entry.server.tsx ? #10332
-
Referring to @sergiodxa's article on dependency injection. https://sergiodxa.com/articles/dependency-injection-in-remix-loaders-and-actions I want to use the built in remix server and not a custom express server. Would it be ok to add dependencies to loadContext in const cache = new Cache();
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext
) {
loadContext.cache = cache; // inject dependency
} |
Beta Was this translation helpful? Give feedback.
Answered by
sergiodxa
Dec 14, 2024
Replies: 1 comment 1 reply
-
That won't work, entry.server functions run after your loaders, it will be to late for that moment You have to use a custom http server. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ajaishankar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That won't work, entry.server functions run after your loaders, it will be to late for that moment
You have to use a custom http server.