Page Contents

Home > @loopback/rest > DefaultSequence

DefaultSequence class

The default implementation of SequenceHandler.

Signature:

export declare class DefaultSequence implements SequenceHandler 

Implements: SequenceHandler

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);

Constructors

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

Properties

Property Modifiers Type Description
findRoute protected FindRoute  
invoke protected InvokeMethod  
invokeMiddleware protected InvokeMiddleware Optional invoker for registered middleware in a chain. To be injected via SequenceActions.INVOKE_MIDDLEWARE.
parseParams protected ParseParams  
reject   Reject  
send   Send  

Methods

Method Modifiers Description
handle(context)   <p>Runs the default sequence. Given a handler context (request and response), running the sequence will produce a response or an error.</p><p>Default sequence executes these steps - Executes middleware for CORS, OpenAPI spec endpoints - 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.</p>