Skip to content

arckit-dev/pipeline

Repository files navigation

@arckit/pipeline

Type-safe middleware pipeline builder with parallel execution and React provider wrapping.

npm version npm downloads bundle size codecov TypeScript

📑 Table of Contents

🪧 About

Framework-agnostic middleware pipeline engine. Provides the core execution model for composing middlewares sequentially or in parallel, accumulating a typed context, and wrapping React providers. Used as the foundation for framework-specific builders (page, layout, route, action).

📦 Installation

pnpm add @arckit/pipeline

🚀 Usage

Render pipeline

import { render, withFetch, withMap } from '@arckit/pipeline';

const middlewares = [
  withFetch('users', async () => fetchUsers()),
  withMap('count', ({ users }) => users.length)
];

const page = render(middlewares)(async ({ users, count }, props) => (
  <UserList users={users} count={count} />
));

Shared middlewares

import { withFetch, withMap } from '@arckit/pipeline';

// withFetch: async data fetching into context
const loadUsers = withFetch('users', async () => fetchUsers());

// withMap: synchronous value derivation
const countUsers = withMap('count', ({ users }) => users.length);

📖 API

Export Description
render(middlewares) Creates an execution function from a middleware array. Handles sequential/parallel execution and provider wrapping.
applyProviders(providers, content) Wraps React content with provider components.
withFetch(key, fetcher) Middleware: fetches async data into context.
withMap(key, mapper) Middleware: derives a synchronous value into context.
Provider Type for React provider configuration (component + props).
Merge<A, B> Utility type for merging context types.

🤗 Contributing

See CONTRIBUTING.md for details.

📝 License

MIT © Marc Gavanier

About

Type-safe middleware pipeline builder with parallel execution and React provider wrapping

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors