Skip to content

Commit

Permalink
INT: added disableMiddleware decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
kukjevov committed Apr 27, 2022
1 parent 1c94800 commit 4275901
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 11.1.0 (2022-04-27)

### Features

- new `DisableMiddleware` decorator, that allows disabling of specified middleware

## Version 11.0.1 (2022-04-07)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export {DELETE, GET, HEAD, POST, PUT, PATCH, RESTClient, ResponseTransformFunc,
export {RestTransferStateService} from './transferState/restTransferState.service';
export {ParametersMetadata, RestCaching, RestDisabledInterceptors, RestHttpHeaders, RestMethod, RestParameters, RestReportProgress, RestResponseTransform, RestResponseType, KeyIndex, ParametersTransformMetadata, RestMiddleware, RestMiddlewareRunMethod, RestMethodMiddlewares, NotType, BuildMiddlewaresFn, ParametersMiddlewaresMetadata, ParametersTransformsObj, RestDateApi, RestProgressIndicatorGroup} from './rest/rest.interface';
export {HTTP_HEADER_ACCEPT, HTTP_HEADER_CONTENT_TYPE} from './rest/constants';
export {Body, BaseUrl, DefaultHeaders, Header, Headers, JsonContentType, ParameterTransform, Path, Produces, Query, QueryObject, ResponseTransform, FullHttpResponse, ReportProgress, DisableInterceptor, ProgressIndicatorGroup, AcceptAny, Cache, TextContentType} from './rest/decorators';
export {Body, BaseUrl, DefaultHeaders, Header, Headers, JsonContentType, ParameterTransform, Path, Produces, Query, QueryObject, ResponseTransform, FullHttpResponse, ReportProgress, DisableInterceptor, ProgressIndicatorGroup, AcceptAny, Cache, TextContentType, DisableMiddleware} from './rest/decorators';
export {REST_METHOD_MIDDLEWARES, REST_MIDDLEWARES_ORDER, REST_DATE_API} from './rest/tokens';
export {BASIC_DEFAULT_REST_METHOD_MIDDLEWARES, BASIC_DEFAULT_REST_MIDDLEWARES_ORDER} from './rest/defaults';
export {ReportProgressMiddleware, IgnoredInterceptorsMiddleware, ResponseTransformMiddleware, ResponseTypeMiddleware, ProducesMiddleware, BodyParameterMiddleware, HeaderParameterMiddleware, PathParameterMiddleware, QueryObjectParameterMiddleware, QueryParameterMiddleware, HeadersMiddleware, CacheMiddleware, LoggerMiddleware, ProgressIndicatorGroupMiddleware} from './rest/middlewares';
Expand Down
19 changes: 19 additions & 0 deletions src/rest/decorators/disableMiddleware.decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Type} from '@angular/core';
import {not, RESTClient, RestMethodMiddlewares, RestMiddleware} from '@anglr/rest';

/**
* Allows disabling of specified middleware
* @param middleware - Middleware that will be disabled
*/
export function DisableMiddleware(middleware: Type<RestMiddleware>)
{
return function<TDecorated>(_target: RESTClient, _propertyKey: string, descriptor: RestMethodMiddlewares |
TDecorated): TypedPropertyDescriptor<any>
{
const descr = descriptor as RestMethodMiddlewares;

descr.middlewareTypes?.push(not(middleware));

return descr;
};
}
1 change: 1 addition & 0 deletions src/rest/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './baseUrl.decorator';
export * from './cache.decorator';
export * from './defaultHeaders.decorator';
export * from './disableInterceptor.decorator';
export * from './disableMiddleware.decorator';
export * from './fullHttpResponse.decorator';
export * from './headers.decorator';
export * from './jsonContentType.decorator';
Expand Down

0 comments on commit 4275901

Please sign in to comment.