Class HttpActionDecorator

Hierarchy

  • HttpActionDecorator

Constructors

Properties

t: HttpAction = ...

Methods

  • Arbitrary value container that can be read in RouterParameterResolver and all HTTP workflow events (like authentication).

    Example

    class My Controller {
    @http.GET('/assets').data('authGroup', 'admin')
    assets() {}
    }

    Parameters

    • name: string
    • value: any

    Returns void

  • Parameters

    • Rest ...middlewares: HttpActionMiddleware[]

    Returns void

  • Parameters

    • target: ClassType<any>
    • property: undefined | string
    • Optional parameterIndexOrDescriptor: any

    Returns void

  • Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.


    class UserResolver {
    resolve(context: RouteParameterResolverContext): any | Promise<any> {
    return new User();
    }
    }

    class MyController {
    @http.GET()
    @http.resolveParameter(User, UserResolver)
    myAction(user: User) {
    }
    }

    new App({providers: [UserResolver]}).run();

    Parameters

    Returns void

  • Adds a parameter resolver for parameters based on its name. Use .resolveParameter() for class-based resolving.


    class UserResolver {
    resolve(context: RouteParameterResolverContext): any | Promise<any> {
    return new User();
    }
    }

    class MyController {
    @http.GET()
    @http.resolveParameterByName('user', UserResolver)
    myAction(user: User) {
    }
    }

    new App({providers: [UserResolver]}).run();

    Parameters

    Returns void

  • Adds additional information about what HTTP status codes are available in this route. You can add additionally a description and a response body type.

    The type is used for serialization for responses with the given statusCode.

    This information is available in Deepkit API console.


    http.GET().response<boolean>(200, 'All ok')

    interface User {
    username: string;
    }
    http.GET().response<User>(200, 'User object')

    interface HttpErrorMessage {
    error: string;
    }
    http.GET().response<HttpErrorMessage>(500, 'Error')

    Type Parameters

    • T

    Parameters

    • statusCode: number
    • description: string = ''
    • Optional type: ReceiveType<T>

    Returns void

  • Allows to change the HttpAction object and composite multiple properties into one function.

    Example

    const authGroup = Symbol('authGroup');

    function authGroup(group: 'admin' | 'user') {
    return (action: HttpAction) => {
    action.data.set(authGroup, group);
    };
    }

    class My Controller {
    @http.GET('/assets').use(authGroup('admin'))
    assets() {}
    }

    Parameters

    Returns void

Generated using TypeDoc