Class RsterApiMethod<NAME, DECLARATION>

Rster method class. Used to create a method with @rster/builder.

We use type parameters to more specifically index the typing of the method. This allows us to get the correct typing for the native method. From a functional perspective, the type parameters are not needed.

Type Parameters

  • NAME extends string

    The name of the method.

  • DECLARATION extends AnyParameterDeclaration

    The declaration of the method.

Hierarchy

  • RsterApiMethod

Constructors

  • The constructor of the RsterApiMethod class.

    Type Parameters

    Parameters

    • name: NAME

      The name of the method.

    • description: string[]

      The description of the method.

    • declaration: DECLARATION

      The declaration of the method.

    • Optional httpPath: string

      The http path of the method. Does not include the parent module's path, only the path for the method's condition. If not provided, it will be generated from the name and declaration.

    • Optional httpMethod: Method

      The http method of the method. If not provided, it will be defaulted to ALL.

    • Optional action: ActionFunction<DECLARATION>

      The action of the method. If not provided, it will be defaulted to a method that throws an error.

    Returns RsterApiMethod<NAME, DECLARATION>

Properties

action?: ActionFunction<DECLARATION>

The action of the method. If not provided, it will be defaulted to a method that throws an error.

declaration: DECLARATION

The declaration of the method.

description: string[]

The description of the method.

httpMethod?: Method

The http method of the method. If not provided, it will be defaulted to ALL.

httpPath: string

The http path of the method. Does not include the parent module's path, only the path for the method's condition.

name: NAME

The name of the method.

Methods

  • The native method of the method. This method can be used to call the method directly, without using the rest api.

    Returns NeedsProperty<RemoveNeverProperties<{
            [key in string | number | symbol]: (NoUndefined<DECLARATION["expectBody"], Record<string, never>> & NoUndefined<DECLARATION["expectQuery"], Record<string, never>> & NoUndefined<DECLARATION["expectParams"], Record<string, never>>)[key]["required"] extends false
                ? never
                : PrimitiveType<(NoUndefined<DECLARATION["expectBody"], Record<string, never>> & NoUndefined<DECLARATION["expectQuery"], Record<string, never>> & NoUndefined<DECLARATION["expectParams"], Record<string, never>>)[key]["type"]>
        }> & Partial<RemoveNeverProperties<{
            [key in string | number | symbol]: (NoUndefined<DECLARATION["expectBody"], Record<string, never>> & NoUndefined<DECLARATION["expectQuery"], Record<string, never>> & NoUndefined<DECLARATION["expectParams"], Record<string, never>>)[key]["required"] extends false
                ? PrimitiveType<(NoUndefined<DECLARATION["expectBody"], Record<string, never>> & NoUndefined<DECLARATION["expectQuery"], Record<string, never>> & NoUndefined<DECLARATION["expectParams"], Record<string, never>>)[key]["type"]>
                : never
        }>>> extends true
        ? ((args) => RsterReturnType<DECLARATION>)
        : ((args?) => RsterReturnType<DECLARATION>)

    The native method of the method.

  • Input the method into a Context object. This will add the method to the context, and it will be used for requests. Defaults to the current context.

    Parameters

    • Optional ctx: Context

      The context to add the method to. Defaults to the current context.

    Returns void

Generated using TypeDoc