getOptionalMiddleware<T> function
Conditionally runs optional middleware or skips middleware
Example:
getOptionalMiddleware(
(context, next) => context.user.isAdmin,
addFieldsForAdmin
);
Implementation
Middleware<T> getOptionalMiddleware<T>(
condition,
Middleware<T> optionalMiddleware,
) {
branchMiddlewareCondition<T>(condition);
return getBranchMiddleware(condition, optionalMiddleware, skipMiddleware);
}