Spaces:
Sleeping
Sleeping
File size: 675 Bytes
cd6720a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import { Observable } from 'rxjs';
import { ExecutionContext } from '../features/execution-context.interface.js';
/**
* Interface describing a global preRequest hook for microservices.
*
* Hooks are executed before guards, allowing setup of context (e.g. AsyncLocalStorage)
* that is available to all downstream enhancers.
*
* @example
* ```typescript
* const als = new AsyncLocalStorage();
* app.registerPreRequestHook((context, next) => {
* als.enterWith({ correlationId: uuid() });
* return next();
* });
* ```
*
* @publicApi
*/
export interface PreRequestHook {
(context: ExecutionContext, next: () => Observable<unknown>): Observable<unknown>;
}
|