UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

91 lines (48 loc) 1.75 kB
--- lang: en title: 'API docs: core.application.server' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/core permalink: /doc/en/lb4/apidocs.core.application.server.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/core](./core.md) &gt; [Application](./core.application.md) &gt; [server](./core.application.server.md) ## Application.server() method Bind a Server constructor to the Application's master context. Each server constructor added in this way must provide a unique prefix to prevent binding overlap. **Signature:** ```typescript server<T extends Server>(ctor: Constructor<T>, nameOrOptions?: string | BindingFromClassOptions): Binding<T>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> ctor </td><td markdown="1"> [Constructor](./context.constructor.md)<!-- -->&lt;T&gt; </td><td markdown="1"> </td></tr> <tr><td markdown="1"> nameOrOptions </td><td markdown="1"> string \| [BindingFromClassOptions](./context.bindingfromclassoptions.md) </td><td markdown="1"> _(Optional)_ Optional override for name or options. </td></tr> </tbody></table> **Returns:** [Binding](./context.binding.md)<!-- -->&lt;T&gt; Binding for the server class ## Example ```ts app.server(RestServer); // This server constructor will be bound under "servers.RestServer". app.server(RestServer, "v1API"); // This server instance will be bound under "servers.v1API". ```