@loopback/docs
Version:
Documentation for LoopBack 4
48 lines (30 loc) • 1.21 kB
Markdown
---
lang: en
title: 'API docs: core.application.server'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.core.application.server.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/core](./core.md) > [Application](./core.application.md) > [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.
<b>Signature:</b>
```typescript
server<T extends Server>(ctor: Constructor<T>, name?: string): Binding<T>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| ctor | <code>Constructor<T></code> | |
| name | <code>string</code> | Optional override for key name. |
<b>Returns:</b>
`Binding<T>`
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".
```