Skip to content

Instantly share code, notes, and snippets.

View README.md

Pipeline

This is a simple functional pipeline implementation that allows the user to execute middleware through a series of sequential steps. It also exposes a compose function for chaining together higher order components.

Pipeline/Middleware Usage

import pipeline, { Middleware } from "./pipeline";

const firstStep: Middlware<any, any> = async (payload, next) => {
  console.log(payload);
@Curtis017
Curtis017 / index.ts
Created Mar 8, 2019
Simple middleware implementation using typescript and ES6
View index.ts
import pipeline, { Middleware } from './pipeline';
const step1: Middleware<any, any> = (req, res, next) => {
if (req.body) {
console.log(`STEP 1: \n req: ${JSON.stringify(req)}\n res: ${JSON.stringify(res)}`);
next();
}
}
const step2: Middleware<any, any> = async (req, res, next) => {