Skip to content

Commit

Permalink
feat: support asynchronous subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Nov 27, 2024
1 parent ea3a15e commit caa6859
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 279 deletions.
4 changes: 0 additions & 4 deletions packages/@wroud/flow-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ All notable changes to this project will be documented in this file.
## 0.2.0 (2024-11-26)

<!-- changelog -->
### ✨ Features

- base implementation ([74bb7e2](https://github.com/Wroud/foundation/commit/74bb7e2))

### 🩹 Fixes

- do not copy data object ([02ce20a](https://github.com/Wroud/foundation/commit/02ce20a))
Expand Down
17 changes: 0 additions & 17 deletions packages/@wroud/flow-middleware/src/FlowMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { MiddlewareRequest } from "./MiddlewareRequest.js";
import type { IErrorMiddleware } from "./interfaces/IErrorMiddleware.js";
import type { ILogger } from "@wroud/api-logger";

/**
* Singleton class to register and manage middlewares.
* @template Data - The shape of the request data.
*/
export class FlowMiddleware<Data = Record<string, any>>
implements IFlowMiddleware<Data>
{
Expand All @@ -20,29 +16,16 @@ export class FlowMiddleware<Data = Record<string, any>>
this.errorMiddlewares = [];
}

/**
* Registers a middleware globally.
* @param {Middleware<Data>} middleware - The middleware function to register.
*/
public use(...middleware: IMiddleware<Data>[]): this {
this.middlewares.push(...middleware);
return this;
}

/**
* Registers an error-handling middleware globally.
* @param {ErrorMiddleware<Data>} errorMiddleware - The error middleware function to register.
*/
public error(...errorMiddleware: IErrorMiddleware<Data>[]): this {
this.errorMiddlewares.push(...errorMiddleware);
return this;
}

/**
* Creates a new MiddlewareRequest instance.
* @param {Data} initialData - Initial data for the request.
* @returns {MiddlewareRequest<Data>} A new MiddlewareRequest instance.
*/
public createRequest(
initialData: Data = {} as Data,
): IMiddlewareRequest<Data> {
Expand Down
Loading

0 comments on commit caa6859

Please sign in to comment.