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>, nameOrOptions?: string | BindingFromClassOptions): Binding<T>;

Parameters

Parameter Type Description
ctor Constructor<T>  
nameOrOptions string | BindingFromClassOptions (Optional) Optional override for name or options.

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