Skip to content

Class: Controller

Callable type representing a method exposed to an API at a path pattern in the format/path/:param. When invoked with an argument set, creates an instance of Operation which is executed by the Manager. There are two ways to invoke a controller instance: 1) untrustedly, using Controller.prototype.try, which first passes the argument set through an optional authorizer function, or 2) trustedly, using (), which bypasses the authorizer. In both cases, the argument set will first be validated by the Controller.schema. Optionally, dependencies and dependents may also be specified as an array of path patterns which will be evaluated at invocation and transferred to the resulting operation.

Hierarchy

Callable

Controller

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Controller(target: Function): Controller

Overrides Callable.constructor

Defined in lib/control/Controller.ts:41

Parameters:

Name Type Description
target Function The function to be transferred to all generated operations.

Returns: Controller

Properties

call

call: Function

Inherited from Callable.call

Defined in lib/utility/Callable.ts:6

The function that will be executed when the instance is invoked.


arguments

arguments: any

Inherited from Callable.arguments

Defined in node_modules/typescript/lib/lib.es5.d.ts:302


authorizer

authorizer: Function

Defined in lib/control/Controller.ts:24

A function (args) => {...}that will be used to authorize invocations made using Controller.prototype.try. Should return an object if the argument set was valid, or an instance of State to abort the operation.


caller

caller: Function

Inherited from Callable.caller

Defined in node_modules/typescript/lib/lib.es5.d.ts:303


dependencies

dependencies: Array‹string› = []

Defined in lib/control/Controller.ts:18

An array of path patterns.


dependents

dependents: Array‹string› = []

Defined in lib/control/Controller.ts:20

An array of path patterns.


instance

instance: Function

Defined in lib/control/Controller.ts:26

An optional function returning an object to which the controller function will be bound before invocation.


isCacheable

isCacheable: boolean

Defined in lib/control/Controller.ts:30

Determines whether the instance represents a cacheable operation.


isRead

isRead: boolean

Defined in lib/control/Controller.ts:28

Determines whether the instance represents a read or write operation.


Readonly length

length: number

Inherited from Callable.length

Defined in node_modules/typescript/lib/lib.es5.d.ts:299


pattern

pattern: string

Defined in lib/control/Controller.ts:16

A path pattern


prototype

prototype: any

Inherited from Callable.prototype

Defined in node_modules/typescript/lib/lib.es5.d.ts:298


validator

validator: Schema | Function = new Schema()

Defined in lib/control/Controller.ts:22

A Schema, or a function that evaluates to one, which will be used to validate all invocations of the instance. This allows schemas to be evaluated when needed, prevent circular dependencies at import time.

Accessors

schema

get schema(): Schema

Defined in lib/control/Controller.ts:33

The Schema, which will be used to validate all invocations of the instance. Evaluates the Controller.prototype.validator if necessary, replacing it with the resulting schema.

Returns: Schema

Methods

apply

apply(this: Function, thisArg: any, argArray?: any): any

Inherited from Callable.apply

Defined in node_modules/typescript/lib/lib.es5.d.ts:278

Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.

Parameters:

Name Type Description
this Function -
thisArg any The object to be used as the this object.
argArray? any A set of arguments to be passed to the function.

Returns: any


bind

bind(this: Function, thisArg: any, ...argArray: any[]): any

Inherited from Callable.bind

Defined in node_modules/typescript/lib/lib.es5.d.ts:293

For a given function, creates a bound function that has the same body as the original function. The this object of the bound function is associated with the specified object, and has the specified initial parameters.

Parameters:

Name Type Description
this Function -
thisArg any An object to which the this keyword can refer inside the new function.
...argArray any[] A list of arguments to be passed to the new function.

Returns: any


call

call(this: Function, thisArg: any, ...argArray: any[]): any

Inherited from Callable.call

Defined in node_modules/typescript/lib/lib.es5.d.ts:285

Calls a method of an object, substituting another object for the current object.

Parameters:

Name Type Description
this Function -
thisArg any The object to be used as the current object.
...argArray any[] A list of arguments to be passed to the method.

Returns: any


toString

toString(): string

Inherited from Callable.toString

Defined in node_modules/typescript/lib/lib.es5.d.ts:296

Returns a string representation of a function.

Returns: string


try

try(args: object): Promise‹any›

Defined in lib/control/Controller.ts:90

When invoked, authorizes the argument set args, then invokes the instance trustedly.

Parameters:

Name Type Description
args object An argument set.

Returns: Promise‹any›