### Class: httphandler = new HttpHandler()

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
handleRequest | `anonymous` |  | exported public |

#### constructor(_rootContext: Context) : HttpHandler

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
_rootContext | `Context` |  |  |

#### describeApiPaths() : PathObject

#### findRoute(request: Request) : ResolvedRoute

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  |

#### getApiDefinitions() : SchemasObject

#### registerApiDefinitions(defs: SchemasObject) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
defs | `SchemasObject` |  |  |

#### registerController(spec: ControllerSpec, controllerCtor: ControllerClass<T>, controllerFactory: ControllerFactory<T>) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `ControllerSpec` |  |  |
controllerCtor | `ControllerClass<T>` |  |  |
controllerFactory | `ControllerFactory<T>` |  | optional |

#### registerRoute(route: RouteEntry) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  |

### Namespace: RestBindings

RestServer-specific bindings

### Namespace: RestBindings.Http

Request-specific bindings

### const RestBindings.Http.CONTEXT = BindingKey.create<Context>( 'rest.http.request.context', )

Binding key for setting and injecting the http request context

### const RestBindings.Http.REQUEST = BindingKey.create<Request>('rest.http.request')

Binding key for setting and injecting the http request

### const RestBindings.Http.RESPONSE = BindingKey.create<Response>('rest.http.response')

Binding key for setting and injecting the http response

### Namespace: RestBindings.SequenceActions

Bindings for potential actions that could be used in a sequence

### const RestBindings.SequenceActions.FIND_ROUTE = BindingKey.create<FindRoute>( 'rest.sequence.actions.findRoute', )

Binding key for setting and injecting a route finding function

### const RestBindings.SequenceActions.INVOKE_METHOD = BindingKey.create<InvokeMethod>( 'rest.sequence.actions.invokeMethod', )

Binding key for setting and injecting a controller route invoking function

### const RestBindings.SequenceActions.LOG_ERROR = BindingKey.create<LogError>( 'rest.sequence.actions.logError', )

Binding key for setting and injecting an error logging function

### const RestBindings.SequenceActions.PARSE_PARAMS = BindingKey.create<ParseParams>( 'rest.sequence.actions.parseParams', )

Binding key for setting and injecting a parameter parsing function

### const RestBindings.SequenceActions.REJECT = BindingKey.create<Reject>( 'rest.sequence.actions.reject', )

Binding key for setting and injecting a bad response writing function

### const RestBindings.SequenceActions.SEND = BindingKey.create<Send>('rest.sequence.actions.send')

Binding key for setting and injecting a response writing function

### const RestBindings.API_SPEC = BindingKey.create<OpenApiSpec>('rest.apiSpec')

Binding key for setting and injecting an OpenAPI spec

### const RestBindings.BIND_ELEMENT = BindingKey.create<BindElement>('bindElement')

Binding key for setting and injecting a wrapper function for setting values on a given context

### const RestBindings.CONFIG = CoreBindings.APPLICATION_CONFIG.deepProperty('rest')

Binding key for setting and injecting RestComponentConfig

### const RestBindings.GET_FROM_CONTEXT = BindingKey.create<GetFromContext>( 'getFromContext', )

Binding key for setting and injecting a wrapper function for retrieving values from a given context

### const RestBindings.HANDLER = BindingKey.create<HttpHandler>('rest.handler')

Internal binding key for http-handler

### const RestBindings.HOST = BindingKey.create<string | undefined>('rest.host')

Binding key for setting and injecting the host name of RestServer

### const RestBindings.PORT = BindingKey.create<number>('rest.port')

Binding key for setting and injecting the port number of RestServer

### const RestBindings.PROTOCOL = BindingKey.create<'http' | 'https'>('rest.protocol')

Binding key for setting and injecting the protocol of RestServer

### const RestBindings.SEQUENCE = BindingKey.create<SequenceHandler>('rest.sequence')

Binding key for setting and injecting a Sequence

### const RestBindings.URL = BindingKey.create<string>('rest.url')

Binding key for setting and injecting the URL of RestServer

### Function: parseOperationArgs

#### parseOperationArgs(request: Request, route: ResolvedRoute) : Promise<OperationArgs>

Parses the request to derive arguments to be passed in for the Application controller method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  | Incoming HTTP request
route | `ResolvedRoute` |  |  |

### Class: bindelementprovider = new BindElementProvider()

#### constructor(context: Context) : BindElementProvider

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `Context` |  |  |

#### action(key: string) : Binding

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  |

#### value() : BindElement

### Class: findrouteprovider = new FindRouteProvider()

#### constructor(context: Context, handler: HttpHandler) : FindRouteProvider

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `Context` |  |  |
handler | `HttpHandler` |  |  |

#### action(request: Request) : ResolvedRoute

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  |

#### value() : FindRoute

### Class: getfromcontextprovider = new GetFromContextProvider()

#### constructor(context: Context) : GetFromContextProvider

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `Context` |  |  |

#### action(key: string) : Promise<BoundValue>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  |

#### value() : GetFromContext

### Class: invokemethodprovider = new InvokeMethodProvider()

#### constructor(context: Context) : InvokeMethodProvider

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `Context` |  |  |

#### action(route: RouteEntry, args: OperationArgs) : Promise<OperationRetval>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  |
args | `OperationArgs` |  |  |

#### value() : InvokeMethod

### Class: logerrorprovider = new LogErrorProvider()

#### action(err: Error, statusCode: number, req: Request) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
err | `Error` |  |  |
statusCode | `number` |  |  |
req | `Request` |  |  |

#### value() : LogError

### Class: parseparamsprovider = new ParseParamsProvider()

Provides the function for parsing args in requests at runtime.

#### value() : parseOperationArgs

### Class: rejectprovider = new RejectProvider()

#### constructor(logError: LogError) : RejectProvider

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
logError | `LogError` |  |  |

#### action(__namedParameters, error: Error) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
__namedParameters | `anonymous` |  |  |
error | `Error` |  |  |

#### value() : Reject

### Class: sendprovider = new SendProvider()

Provides the function that populates the response object with the results of the operation.

#### value() : writeResultToResponse

### Class: restapplication = new RestApplication()

An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

#### constructor(config: ApplicationConfig) : RestApplication

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
config | `ApplicationConfig` |  | optional | An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

#### requestHandler() : HttpRequestListener

Handle incoming HTTP(S) request by invoking the corresponding Controller method via the configured Sequence.

#### restServer() : RestServer

The main REST server instance providing REST API for this application.

#### api(spec: OpenApiSpec) : Binding

Set the OpenAPI specification that defines the REST API schema for this application. All routes, parameter definitions and return types will be defined in this way.

Note that this will override any routes defined via decorators at the controller level (this function takes precedent).

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `OpenApiSpec` |  |  | The OpenAPI specification, as an object.

#### handler(handlerFn: SequenceFunction) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
handlerFn | `SequenceFunction` |  |  | An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

#### route(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass<T>, controllerFactory: ControllerFactory<T>, methodName: string) : Binding

Register a new Controller-based route.

    class MyController {
      greet(name: string) {
        return `hello ${name}`;
      }
    }
    app.route('get', '/greet', operationSpec, MyController, 'greet');

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
verb | `string` |  |  | HTTP verb of the endpoint
path | `string` |  |  | URL path of the endpoint
spec | `OperationObject` |  |  | The OpenAPI spec describing the endpoint (operation)
controllerCtor | `ControllerClass<T>` |  |  | Controller constructor
controllerFactory | `ControllerFactory<T>` |  |  | A factory function to create controller instance
methodName | `string` |  |  | The name of the controller method

#### route(route: RouteEntry) : Binding

Register a new route.

    function greet(name: string) {
     return `hello ${name}`;
    }
    const route = new Route('get', '/', operationSpec, greet);
    app.route(route);

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  | The route to add.

#### sequence(sequence: Constructor<SequenceHandler>) : Binding

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
sequence | `Constructor<SequenceHandler>` |  |  | An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

#### server(server: Constructor<Server>, name: undefined | string) : Binding

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
server | `Constructor<Server>` |  |  | An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.
name | `undefined | string` |  | optional | An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

### const ERR_NO_MULTI_SERVER = format( 'RestApplication does not support multiple servers!', 'To create your own server bindings, please extend the Application class.', )

### const SequenceActions = RestBindings.SequenceActions

### Class: restcomponent = new RestComponent()

#### constructor(app: Application, config: RestComponentConfig) : RestComponent

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `Application` |  |  |
config | `RestComponentConfig` |  | optional |

### Interface: RestComponentConfig

### Class: restserver = new RestServer()

A REST API server for use with Loopback. Add this server to your application by importing the RestComponent.

    const app = new MyApplication();
    app.component(RestComponent);

To add additional instances of RestServer to your application, use the `.server` function:

    app.server(RestServer, 'nameOfYourServer');

By default, one instance of RestServer will be created when the RestComponent is bootstrapped. This instance can be retrieved with `app.getServer(RestServer)`, or by calling `app.get('servers.RestServer')` Note that retrieving other instances of RestServer must be done using the server's name:

    const server = await app.getServer('foo')
    // OR
    const server = await app.get('servers.foo');

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestHandler | `HttpRequestListener` |  | exported public | Handle incoming HTTP(S) request by invoking the corresponding Controller method via the configured Sequence.

#### constructor(app: Application, options: RestServerConfig) : RestServer

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `Application` |  |  | The application instance (injected via CoreBindings.APPLICATION_INSTANCE).
options | `RestServerConfig` |  | optional | The configuration options (injected via RestBindings.CONFIG).

#### listening() : boolean

#### url() : string | undefined

#### api(spec: OpenApiSpec) : Binding

Set the OpenAPI specification that defines the REST API schema for this server. All routes, parameter definitions and return types will be defined in this way.

Note that this will override any routes defined via decorators at the controller level (this function takes precedent).

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `OpenApiSpec` |  |  | The OpenAPI specification, as an object.

#### controller(controllerCtor: ControllerClass<ControllerInstance>) : Binding

Register a controller class with this server.

Returns:

The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications.

    class MyController {
    }
    app.controller(MyController).lock();

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
controllerCtor | `ControllerClass<ControllerInstance>` |  |  | The controller class (constructor function).

#### getApiSpec() : OpenApiSpec

Get the OpenAPI specification describing the REST API provided by this application.

This method merges operations (HTTP endpoints) from the following sources:

- `app.api(spec)`
- `app.controller(MyController)`
- `app.route(route)`
- `app.route('get', '/greet', operationSpec, MyController, 'greet')`

#### handler(handlerFn: SequenceFunction) : void

Configure a custom sequence function for handling incoming requests.

    app.handler(({request, response}, sequence) => {
      sequence.send(response, 'hello world');
    });

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
handlerFn | `SequenceFunction` |  |  | The handler to invoke for each incoming request.

#### route(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass<I>, controllerFactory: ControllerFactory<I>, methodName: string) : Binding

Register a new Controller-based route.

    class MyController {
      greet(name: string) {
        return `hello ${name}`;
      }
    }
    app.route('get', '/greet', operationSpec, MyController, 'greet');

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
verb | `string` |  |  | HTTP verb of the endpoint
path | `string` |  |  | URL path of the endpoint
spec | `OperationObject` |  |  | The OpenAPI spec describing the endpoint (operation)
controllerCtor | `ControllerClass<I>` |  |  | Controller constructor
controllerFactory | `ControllerFactory<I>` |  |  | A factory function to create controller instance
methodName | `string` |  |  | The name of the controller method

#### route(route: RouteEntry) : Binding

Register a new route.

    function greet(name: string) {
     return `hello ${name}`;
    }
    const route = new Route('get', '/', operationSpec, greet);
    app.route(route);

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  | The route to add.

#### sequence(value: Constructor<SequenceHandler>) : void

Configure a custom sequence class for handling incoming requests.

    class MySequence implements SequenceHandler {
      constructor(
        @inject('send) public send: Send)) {
      }

      public async handle({response}: RequestContext) {
        send(response, 'hello world');
      }
    }

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Constructor<SequenceHandler>` |  |  | The sequence to invoke for each incoming request.

#### start() : Promise<void>

Start this REST API's HTTP/HTTPS server.

#### stop() : Promise<void>

Stop this REST API's HTTP/HTTPS server.

### Interface: HttpServerLike

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestHandler | `HttpRequestListener` |  | exported |

### Interface: RestServerConfig

Valid configuration for the RestServer constructor.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
apiExplorerUrl | `undefined | string` |  | exported optional | Valid configuration for the RestServer constructor.
cors | `cors.CorsOptions` |  | exported optional | Valid configuration for the RestServer constructor.
host | `undefined | string` |  | exported optional | Valid configuration for the RestServer constructor.
port | `undefined | number` |  | exported optional | Valid configuration for the RestServer constructor.
protocol | `|` |  | exported optional | Valid configuration for the RestServer constructor.
sequence | `Constructor<SequenceHandler>` |  | exported optional | Valid configuration for the RestServer constructor.

### Type alias: HttpRequestListener(req: ServerRequest, res: ServerResponse): void

Arguments

Name | Type | Description
--- | --- | ---
req | `ServerRequest` |
res | `ServerResponse` |

### Class: baseroute = new BaseRoute()

Base implementation of RouteEntry

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
path | `string` |  | constructorProperty exported public | http request path pattern
spec | `OperationObject` |  | constructorProperty exported public | OpenAPI operation spec
verb | `string` |  | exported public | Base implementation of RouteEntry

#### constructor(verb: string, path: string, spec: OperationObject) : BaseRoute

Construct a new route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
verb | `string` |  |  | http verb
path | `string` |  |  | http request path pattern
spec | `OperationObject` |  |  | OpenAPI operation spec

#### describe() : string

#### invokeHandler(requestContext: Context, args: OperationArgs) : Promise<OperationRetval>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  | Base implementation of RouteEntry
args | `OperationArgs` |  |  | Base implementation of RouteEntry

#### match(request: Request) : ResolvedRoute | undefined

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  | Base implementation of RouteEntry

#### updateBindings(requestContext: Context) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  | Base implementation of RouteEntry

### Class: controllerroute = new ControllerRoute()

A route backed by a controller

#### constructor(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass<T>, controllerFactory: ControllerFactory<T>, methodName: undefined | string) : ControllerRoute

Construct a controller based route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
verb | `string` |  |  | http verb
path | `string` |  |  | http request path
spec | `OperationObject` |  |  | OpenAPI operation spec
controllerCtor | `ControllerClass<T>` |  |  | Controller class
controllerFactory | `ControllerFactory<T>` |  | optional | A factory function to create a controller instance
methodName | `undefined | string` |  | optional | Controller method name, default to `x-operation-name`

#### describe() : string

#### invokeHandler(requestContext: Context, args: OperationArgs) : Promise<OperationRetval>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  | A route backed by a controller
args | `OperationArgs` |  |  | A route backed by a controller

#### updateBindings(requestContext: Context) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  | A route backed by a controller

### Class: route = new Route()

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `OperationObject` |  | constructorProperty exported public |

#### constructor(verb: string, path: string, spec: OperationObject, _handler: Function) : Route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
verb | `string` |  |  |
path | `string` |  |  |
spec | `OperationObject` |  |  |
_handler | `Function` |  |  |

#### describe() : string

#### invokeHandler(requestContext: Context, args: OperationArgs) : Promise<OperationRetval>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  |
args | `OperationArgs` |  |  |

#### updateBindings(requestContext: Context) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  |

### Class: routingtable = new RoutingTable()

Routing table

#### describeApiPaths() : PathObject

#### find(request: Request) : ResolvedRoute

Map a request to a route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  |

#### registerController(spec: ControllerSpec, controllerCtor: ControllerClass<T>, controllerFactory: ControllerFactory<T>) : void

Register a controller as the route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `ControllerSpec` |  |  |
controllerCtor | `ControllerClass<T>` |  |  |
controllerFactory | `ControllerFactory<T>` |  | optional |

#### registerRoute(route: RouteEntry) : void

Register a route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  | A route entry

#### joinPath(basePath: string, path: string) : string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
basePath | `string` |  |  | Routing table
path | `string` |  |  | Routing table

### Interface: ResolvedRoute

A route with path parameters resolved

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
pathParams | `PathParameterValues` |  | exported | A route with path parameters resolved
schemas | `SchemasObject` |  | exported | Server/application wide schemas shared by multiple routes, e.g. model schemas. This is a temporary workaround for missing support for $ref references, see https://github.com/strongloop/loopback-next/issues/435

### Interface: RouteEntry

An entry in the routing table

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
path | `string` |  | exported | http path
spec | `OperationObject` |  | exported | OpenAPI operation spec
verb | `string` |  | exported | http verb

#### describe() : string

#### invokeHandler(requestContext: Context, args: OperationArgs) : Promise<OperationRetval>

A handler to invoke the resolved controller method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  |
args | `OperationArgs` |  |  |

#### match(request: Request) : ResolvedRoute | undefined

Map an http request to a route

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  |  |

#### updateBindings(requestContext: Context) : void

Update bindings for the request context

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestContext | `Context` |  |  |

### Type alias: ControllerClass = Constructor

### Type alias: ControllerFactory(ctx: Context): ValueOrPromise

A factory function to create controller instances synchronously or asynchronously

Arguments

Name | Type | Description
--- | --- | ---
ctx | `Context` |

### Function: createControllerFactoryForBinding

#### createControllerFactoryForBinding(key: string) : ControllerFactory<T>

Create a controller factory function for a given binding key

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Binding key

### Function: createControllerFactoryForClass

#### createControllerFactoryForClass(controllerCtor: ControllerClass<T>) : ControllerFactory<T>

Create a controller factory function for a given class

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
controllerCtor | `ControllerClass<T>` |  |  | Controller class

### Function: createControllerFactoryForInstance

#### createControllerFactoryForInstance(controllerInst: T) : ControllerFactory<T>

Create a controller factory function for a given instance

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
controllerInst | `T` |  |  |

### Function: createResolvedRoute

#### createResolvedRoute(route: RouteEntry, pathParams: PathParameterValues) : ResolvedRoute

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
route | `RouteEntry` |  |  |
pathParams | `PathParameterValues` |  |  |

### Class: defaultsequence = new DefaultSequence()

The default implementation of SequenceHandler.

This class implements default Sequence for the LoopBack framework. Default sequence is used if user hasn't defined their own Sequence for their application.

Sequence constructor() and run() methods are invoked from [[http-handler]] when the API request comes in. User defines APIs in their Application Controller class.

User can bind their own Sequence to app as shown below

    app.bind(CoreBindings.SEQUENCE).toClass(MySequence);

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
reject | `Reject` |  | constructorProperty exported public | The action to take if the invoke returns a rejected promise result (injected via SequenceActions.REJECT).
send | `Send` |  | constructorProperty exported public | The action to merge the invoke result with the response (injected via SequenceActions.SEND)

#### constructor(findRoute: FindRoute, parseParams: ParseParams, invoke: InvokeMethod, send: Send, reject: Reject) : DefaultSequence

Constructor: Injects findRoute, invokeMethod & logError methods as promises.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
findRoute | `FindRoute` |  |  | Finds the appropriate controller method, spec and args for invocation (injected via SequenceActions.FIND_ROUTE).
parseParams | `ParseParams` |  |  | The parameter parsing function (injected via SequenceActions.PARSE_PARAMS).
invoke | `InvokeMethod` |  |  | Invokes the method specified by the route (injected via SequenceActions.INVOKE_METHOD).
send | `Send` |  |  | The action to merge the invoke result with the response (injected via SequenceActions.SEND)
reject | `Reject` |  |  | The action to take if the invoke returns a rejected promise result (injected via SequenceActions.REJECT).

#### handle(context: RequestContext) : Promise<void>

Runs the default sequence. Given a handler context (request and response), running the sequence will produce a response or an error.

Default sequence executes these steps

- Finds the appropriate controller method, swagger spec and args for invocation
- Parses HTTP request to get API argument list
- Invokes the API which is defined in the Application Controller
- Writes the result from API into the HTTP response
- Error is caught and logged using 'logError' if any of the above steps in the sequence fails with an error.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `RequestContext` |  |  | The request context: HTTP request and response objects, per-request IoC container and more.

### Interface: SequenceHandler

A sequence handler is a class implementing sequence of actions required to handle an incoming request.

#### handle(context: RequestContext) : Promise<void>

Handle the request by running the configured sequence of actions.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
context | `RequestContext` |  |  | The request context: HTTP request and response objects, per-request IoC container and more.

### Type alias: SequenceFunction(context: RequestContext, sequence: DefaultSequence):

A sequence function is a function implementing a custom sequence of actions to handle an incoming request.

Arguments

Name | Type | Description
--- | --- | ---
context | `RequestContext` |
sequence | `DefaultSequence` |

### Interface: HandlerContext

An object holding HTTP request, response and other data needed to handle an incoming HTTP request.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `Request` |  | exported | An object holding HTTP request, response and other data needed to handle an incoming HTTP request.
response | `Response` |  | exported | An object holding HTTP request, response and other data needed to handle an incoming HTTP request.

### Type alias: BindElement(key: string): Binding

Arguments

Name | Type | Description
--- | --- | ---
key | `string` |

### Type alias: FindRoute(request: Request): ResolvedRoute

Find a route matching the incoming request. Throw an error when no route was found.

Arguments

Name | Type | Description
--- | --- | ---
request | `Request` |

### Type alias: GetFromContext(key: string): Promise<BoundValue>

Arguments

Name | Type | Description
--- | --- | ---
key | `string` |

### Type alias: InvokeMethod(route: RouteEntry, args: OperationArgs): Promise<OperationRetval>

Invokes a method defined in the Application Controller

Returns:

OperationRetval Result from method invocation

Arguments

Name | Type | Description
--- | --- | ---
route | `RouteEntry` |
args | `OperationArgs` | Operation arguments for the method

### Type alias: LogError(err: Error, statusCode: number, request: Request): void

Log information about a failed request.

Returns:

Arguments

Name | Type | Description
--- | --- | ---
err | `Error` | The error reported by request handling code.
statusCode | `number` | Status code of the HTTP response
request | `Request` | The request that failed.

### Type alias: OperationArgs = any[]

### Type alias: OperationRetval = any

### Type alias: ParseParams(request: Request, route: ResolvedRoute): Promise<OperationArgs>

Arguments

Name | Type | Description
--- | --- | ---
request | `Request` |
route | `ResolvedRoute` |

### Type alias: PathParameterValues(key: string): any

Arguments

Name | Type | Description
--- | --- | ---
key | `string` |

### Type alias: Reject(handlerContext: HandlerContext, err: Error): void

Reject the request with an error.

Returns:

Arguments

Name | Type | Description
--- | --- | ---
handlerContext | `HandlerContext` | The context object holding HTTP request, response and other data needed to handle an incoming HTTP request.
err | `Error` | The error.

### Type alias: Send(response: Response, result: OperationRetval): void

Send the operation response back to the client.

Returns:

Arguments

Name | Type | Description
--- | --- | ---
response | `Response` | The response the response to send to.
result | `OperationRetval` | The operation result to send.

### Function: writeErrorToResponse

#### writeErrorToResponse(response: Response, error: Error) : void

Write an error into the HTTP response

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
response | `Response` |  |  | HTTP response
error | `Error` |  |  | Error

### Function: writeResultToResponse

#### writeResultToResponse(response: Response, result: OperationRetval) : void

Writes the result from Application controller method into the HTTP response

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
response | `Response` |  |  | HTTP Response
result | `OperationRetval` |  |  | Result from the API to write into HTTP Response