Page Contents

Home > @loopback/rest > DefaultSequence

DefaultSequence class

The default implementation of SequenceHandler.

Signature:

export declare class DefaultSequence implements SequenceHandler 

Constructors

Constructor Modifiers Description
(constructor)(findRoute, parseParams, invoke, send, reject)   Constructor: Injects findRoute, invokeMethod & logError methods as promises.

Properties

Property Modifiers Type Description
findRoute   FindRoute  
invoke   InvokeMethod  
parseParams   ParseParams  
reject   Reject  
send   Send  

Methods

Method Modifiers Description
handle(context)   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.

Remarks

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.

Example

User can bind their own Sequence to app as shown below

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