Page Contents

Home > @loopback/core > Application > server

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:

server<T extends Server>(ctor: Constructor<T>, name?: string): Binding<T>;

Parameters

Parameter Type Description
ctor Constructor<T>  
name string Optional override for key name.

Returns:

Binding<T>

Binding for the server class

Example

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".