@micro.ts/core
Version:
Microservice framework with Typescript
45 lines (44 loc) • 2.44 kB
TypeScript
import { AuthorizeOptions, BrokerFilter, BrokerRouteOptionsResolver } from './types/MethodMetadataTypes';
import { AppErrorHandler } from '../errors/types/ErrorHandlerTypes';
/**
* Use this decorator to guard the method or if used on a controller, guard all controller methods,
* by filtering the request through authorizationChecker server function
* If used on a controller you can bypass this check by usig AllowAnonymous decorator on a method
* Throws NotAuthorized error if the authorizationChecker returns false
* @param options Allows any nested value inside authorize options,
* this object, if exists, will be passed in the authorizationChecker function
*/
export declare function Authorize(options?: AuthorizeOptions): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
/**
* Overrides the controller Authorization guard by disabling it for the methods it decorates
*/
export declare function AllowAnonymous(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
/**
* Register error handler for the handler it decorates
* @param options
*/
export declare function UseErrorHandlers(options: AppErrorHandler[]): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
/**
* Filter controller brokers for this methods
* @param brokers Filter function, applied to the list of brokers enabled for this method's controller
*/
export declare function FilterBrokers(brokers: BrokerFilter): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
export declare function BrokerRouteOptions(resolver: BrokerRouteOptionsResolver): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
/**
* Use this decorator to redirect to another page. You can replace params starting
* with `:` by returning an object from the handler function that has a key with the
* name of the `:param`.
*
* @param url URL to be redirected to when the function handler executes successfully
*
* Example: `url: https://github.com/repos/:owner/:repo`. Returned object from handler:
*
* ```
* {
* owner: "john",
* repo: "doe"
* }
* ```
* Final URL: `https://github.com/repos/john/doe`
*/
export declare function Redirect(url: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;