UNPKG

@loopback/docs

Version:
1,145 lines (762 loc) 26.1 kB
<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/code-themes/sl-theme.css"> <link rel="stylesheet" href="css/main.css"> </head> <body> <div class="navbar navbar-inverse navbar-static-top" role="navigation"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="/">docs.strongloop.com</a> </div> <div id="modules"></div> </div> <div class="row"> <div class="col-lg-3 column scroll-spy-target"> <ul class="nav nav-pills nav-stacked"> <div id="versions"></div> <li class="depth-3"> <a href="#Application">Class: Application</a> </li> <li class="depth-4"> <a href="#19">constructor</a> </li> <li class="depth-4"> <a href="#44">component</a> </li> <li class="depth-4"> <a href="#23">controller</a> </li> <li class="depth-4"> <a href="#36">getServer</a> </li> <li class="depth-4"> <a href="#27">server</a> </li> <li class="depth-4"> <a href="#32">servers</a> </li> <li class="depth-4"> <a href="#40">start</a> </li> <li class="depth-4"> <a href="#42">stop</a> </li> <li class="depth-3"> <a href="#ApplicationConfig">Interface: ApplicationConfig</a> </li> <li class="depth-3"> <a href="#ControllerClass">Type alias: ControllerClass</a> </li> <li class="depth-3"> <a href="#Component">Interface: Component</a> </li> <li class="depth-3"> <a href="#ProviderMap">Interface: ProviderMap</a> </li> <li class="depth-3"> <a href="#133">Function: mountComponent</a> </li> <li class="depth-3"> <a href="#Server">Interface: Server</a> </li> <li class="depth-4"> <a href="#3">start</a> </li> <li class="depth-4"> <a href="#5">stop</a> </li> </ul> </div> <div class="col-lg-9 col-lg-offset-3 column" data-spy="scroll" data-target=".scroll-spy-target" data-offset="0"> <div class="readability"> <section class="code-doc "> <a name="Application"></a> <h3 class="code-ref">Class: application = new Application()</h3> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.</p> </p> <p></p> </div> </section> <section class="code-doc"> <div class="code-arguments-hdr">Properties</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <a name=""></a> <strong class="code-arg-name">options</strong> </td> <td class="code-arg-types"> <code><a href="#ApplicationConfig">ApplicationConfig</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.</p> </p> <p></p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="19"></a> <h4 class="code-ref">constructor(options: <a href="#ApplicationConfig">ApplicationConfig</a>) : Application</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">options</strong> </td> <td class="code-arg-types"> <code><a href="#ApplicationConfig">ApplicationConfig</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.</p> </p> <p></p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="44"></a> <h4 class="code-ref">component(componentCtor: <a href="#Constructor">Constructor</a>, name: undefined) : void</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Add a component to this application and register extensions such as controllers, providers, and servers from the component.</p> </p> <p></p> </div> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">componentCtor</strong> </td> <td class="code-arg-types"> <code><a href="#Constructor">Constructor</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p>The component class to add.</p> </p> </div> </td> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">name</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p><p>Optional component name, default to the class name</p></p> <pre><code class="lang-ts"> <span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> ProductComponent { controllers = [ProductController]; repositories = [ProductRepo, UserRepo]; providers = { [AUTHENTICATION_STRATEGY]: AuthStrategy, [AUTHORIZATION_ROLE]: Role, }; }; app.component(ProductComponent); </code></pre> </p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="23"></a> <h4 class="code-ref">controller(controllerCtor: <a href="#ControllerClass">ControllerClass</a>, name: undefined) : Binding</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Register a controller class with this application.</p> </p> <p></p> </div> Returns: <p><p><p>The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications.</p></p> <pre><code class="lang-ts"><span class="hljs-keyword">class</span> MyController { } app.controller(MyController).lock(); </code></pre> </p> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">controllerCtor</strong> </td> <td class="code-arg-types"> <code><a href="#ControllerClass">ControllerClass</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p>The controller class (constructor function).</p> </p> </div> </td> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">name</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p>Optional controller name, default to the class name</p> </p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="36"></a> <h4 class="code-ref">getServer(target: undefined) : Promise</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Retrieve the singleton instance for a bound constructor.</p> </p> <p></p> </div> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">target</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.</p> </p> <p></p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="27"></a> <h4 class="code-ref">server(ctor: <a href="#Constructor">Constructor</a>, name: undefined) : Binding</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Bind a Server constructor to the Application&#39;s master context. Each server constructor added in this way must provide a unique prefix to prevent binding overlap.</p> </p> <p><pre><code class="lang-ts">app.server(RestServer); <span class="hljs-comment">// This server constructor will be bound under "servers.RestServer".</span> app.server(RestServer, <span class="hljs-string">"v1API"</span>); <span class="hljs-comment">// This server instance will be bound under "servers.v1API".</span> </code></pre> </p> </div> Returns: <p><p>Binding for the server class</p> </p> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">ctor</strong> </td> <td class="code-arg-types"> <code><a href="#Constructor">Constructor</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.</p> </p> <p></p> </div> </td> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">name</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p>Optional override for key name.</p> </p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="32"></a> <h4 class="code-ref">servers(ctors: undefined) : </h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Bind an array of Server constructors to the Application&#39;s master context. Each server added in this way will automatically be named based on the class constructor name with the &quot;servers.&quot; prefix.</p> </p> <p><p><p>If you wish to control the binding keys for particular server instances, use the app.server function instead.</p></p> <pre><code class="lang-ts">app.servers([ RestServer, GRPCServer, ]); <span class="hljs-comment">// Creates a binding for "servers.RestServer" and a binding for</span> <span class="hljs-comment">// "servers.GRPCServer";</span> </code></pre> </p> </div> Returns: <p><p>An array of bindings for the registered server classes</p> </p> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">ctors</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p><p>An array of Server constructors.</p> </p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="40"></a> <h4 class="code-ref">start() : Promise</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Start the application, and all of its registered servers.</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="42"></a> <h4 class="code-ref">stop() : Promise</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Stop the application instance and all of its registered servers.</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="ApplicationConfig"></a> <h3 class="code-ref">Interface: ApplicationConfig</h3> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Configuration for application</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="ControllerClass"></a> <h3 class="code-ref">Type alias: ControllerClass = Constructor</h3> </section> <section class="code-doc "> <a name="Component"></a> <h3 class="code-ref">Interface: Component</h3> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>A component declares a set of artifacts so that they cane be contributed to an application as a group</p> </p> <p></p> </div> </section> <section class="code-doc"> <div class="code-arguments-hdr">Properties</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <a name=""></a> <strong class="code-arg-name">controllers</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>An array of controller classes</p> </p> <p></p> </div> </td> </tr> <tr class="code-arg"> <td> <a name=""></a> <strong class="code-arg-name">providers</strong> </td> <td class="code-arg-types"> <code><a href="#ProviderMap">ProviderMap</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>A map of name/class pairs for binding providers</p> </p> <p></p> </div> </td> </tr> <tr class="code-arg"> <td> <a name=""></a> <strong class="code-arg-name">servers</strong> </td> <td class="code-arg-types"> <code></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>A map of name/class pairs for servers</p> </p> <p></p> </div> </td> </tr> </table> </section> <section class="code-doc "> <a name="ProviderMap"></a> <h3 class="code-ref">Interface: ProviderMap</h3> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>A map of name/class pairs for binding providers</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="133"></a> <h3 class="code-ref">Function: mountComponent</h3> <section class="code-doc "> <a name="133"></a> <h4 class="code-ref">mountComponent(app: <a href="#Application">Application</a>, component: <a href="#Component">Component</a>) : void</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Mount a component to an Application.</p> </p> <p></p> </div> <div class="code-arguments-hdr">Arguments</div> <table class="params code-arguments"> <tr> <th class="hdr-name">Name</th> <th class="hdr-type">Type</th> <th class="hdr-desc">Description</th> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">app</strong> </td> <td class="code-arg-types"> <code><a href="#Application">Application</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p></p> </div> </td> </tr> <tr class="code-arg"> <td> <strong class="code-arg-name">component</strong> </td> <td class="code-arg-types"> <code><a href="#Component">Component</a></code> </td> <td class="code-arg-desc"> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p></p> <p></p> </div> </td> </tr> </table> </section> </section> <section class="code-doc "> <a name="Server"></a> <h3 class="code-ref">Interface: Server</h3> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Defines the requirements to implement a Server for LoopBack applications: start() : Promise<void> stop() : Promise<void> It is recommended that each Server implementation creates its own child Context, which inherits from the parent Application context. This way, any Server-specific bindings will remain local to the Server instance, and will avoid polluting its parent module scope.</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="3"></a> <h4 class="code-ref">start() : Promise</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Start the server</p> </p> <p></p> </div> </section> <section class="code-doc "> <a name="5"></a> <h4 class="code-ref">stop() : Promise</h4> <!-- Used for displaying comments in Class, Interface, Properties Constructor, Function and Parameters of constructor or function. (Excludes Type alias). --> <div class="code-desc"> <p><p>Stop the server</p> </p> <p></p> </div> </section> </div> <div class="intentionally-left-blank"></div> </div> </div> <script src="js/vendor/jquery-1.10.1.min.js"></script> <script src="js/vendor/jquery.scrollTo-1.4.3.1.js"></script> <script src="js/vendor/bootstrap.min.js"></script> <script src="js/main.js"></script> </body> </html>