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

wip - making a standalone middleware library #6027

Draft
wants to merge 32 commits into
base: next
Choose a base branch
from
Draft

wip - making a standalone middleware library #6027

wants to merge 32 commits into from

Conversation

KATT
Copy link
Member

@KATT KATT commented Sep 22, 2024

Closes #

The goal

Move the middleware abstraction and the base of the procedure builder out of tRPC so other libraries can leverage it

Usecases

Create a base trpc middleware lib

  • a future RSC-only library it and only add e.g. .actions() and to make a safe data layer
  • a standalone app can use middleware instead of e.g. a express middleware
  • @trpc/server can use it and add .query() / .mutation() etc

The how

🚧 The real way of doing this should likely be done like how redux toolkit does it

Right now - I've mainly cared about the types

  • I've created a middleware.ts that is the "base module"
  • Trying to work out how middlewareExtend.test.ts could extend the base module and inject options into the middleware chain and new builder methods without polluting the global scope

modules.test.ts is a start of a builder that can be extended by libraries

References

The principle should be possible: https://x.com/eskimojo/status/1837827507795501323

Copy link

railway-app bot commented Sep 22, 2024

🚅 Deployed to the trpc-pr-6027 environment in trpc-sse-and-websockets

Service Status Web Updated (UTC)
next-prisma-websockets-starter ❌ Build Failed (View Logs) Sep 27, 2024 at 10:18 am
next-sse-chat ❌ Build Failed (View Logs) Web Sep 27, 2024 at 10:18 am

Copy link

vercel bot commented Sep 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ❌ Failed (Inspect) Sep 27, 2024 10:18am
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 10:18am
www ❌ Failed (Inspect) Sep 27, 2024 10:18am

@KATT KATT changed the title wip - making a middleware library wip - making a standalone middleware library Sep 22, 2024
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.

1 participant