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: pipe universal middlewares #19

Merged
merged 6 commits into from
Aug 22, 2024
Merged

feat: pipe universal middlewares #19

merged 6 commits into from
Aug 22, 2024

Conversation

magne4000
Copy link
Owner

@magne4000 magne4000 commented Aug 21, 2024

Add the pipe function to compose Universal Middlewares and Handlers

const wrappedHandler = pipe(
  () => ({ a: 1 }),
  async (_: Request, ctx: { a: number }) => {
    return {
      ...ctx,
      b: 2,
    };
  },
  (_: Request, ctx: { a: number; b: number }) =>
    new Response(String(ctx.a + ctx.b)),
);

@magne4000
Copy link
Owner Author

@mindplay-dk I realized that with current architecture we can have a proper composition function (with correct types chaining). So here it is :)

@magne4000 magne4000 changed the title feat: compose universal middlewares feat: pipe universal middlewares Aug 21, 2024
@magne4000 magne4000 merged commit c13e8f5 into main Aug 22, 2024
5 checks passed
@magne4000 magne4000 deleted the compose branch August 22, 2024 06:15
@github-actions github-actions bot mentioned this pull request Nov 19, 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