---
lang: en
title: 'API docs: rest.restapplication'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.restapplication.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [RestApplication](./rest.restapplication.md)

## RestApplication class

An implementation of the Application class that automatically provides an instance of a REST server. This application class is intended to be a single-server implementation. Any attempt to bind additional servers will throw an error.

**Signature:**

```typescript
export declare class RestApplication extends Application implements HttpServerLike 
```
**Extends:** [Application](./core.application.md)

**Implements:** [HttpServerLike](./rest.httpserverlike.md)

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(parent)](./rest.restapplication._constructor_.md)


</td><td>


</td><td>

Create a REST application with the given parent context


</td></tr>
<tr><td>

[(constructor)(config, parent)](./rest.restapplication._constructor__1.md)


</td><td>


</td><td>

Create a REST application with the given configuration and parent context


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[requestHandler](./rest.restapplication.requesthandler.md)


</td><td>

`readonly`


</td><td>

[HttpRequestListener](./rest.httprequestlistener.md)


</td><td>

Handle incoming HTTP(S) request by invoking the corresponding Controller method via the configured Sequence.


</td></tr>
<tr><td>

[restServer](./rest.restapplication.restserver.md)


</td><td>

`readonly`


</td><td>

[RestServer](./rest.restserver.md)


</td><td>

The main REST server instance providing REST API for this application.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[api(spec)](./rest.restapplication.api.md)


</td><td>


</td><td>

Set the OpenAPI specification that defines the REST API schema for this application. All routes, parameter definitions and return types will be defined in this way.

Note that this will override any routes defined via decorators at the controller level (this function takes precedent).


</td></tr>
<tr><td>

[basePath(path)](./rest.restapplication.basepath.md)


</td><td>


</td><td>

Configure the `basePath` for the rest server


</td></tr>
<tr><td>

[bodyParser(bodyParserClass, address)](./rest.restapplication.bodyparser.md)


</td><td>


</td><td>

Bind a body parser to the server context


</td></tr>
<tr><td>

[exportOpenApiSpec(outFile, log)](./rest.restapplication.exportopenapispec.md)


</td><td>


</td><td>

Export the OpenAPI spec to the given json or yaml file


</td></tr>
<tr><td>

[expressMiddleware(key, middleware, options)](./rest.restapplication.expressmiddleware.md)


</td><td>


</td><td>

Bind an Express middleware to this server context


</td></tr>
<tr><td>

[expressMiddleware(middlewareFactory, middlewareConfig, options)](./rest.restapplication.expressmiddleware_1.md)


</td><td>


</td><td>

Bind an Express middleware to this server context


</td></tr>
<tr><td>

[handler(handlerFn)](./rest.restapplication.handler.md)


</td><td>


</td><td>


</td></tr>
<tr><td>

[middleware(middleware, options)](./rest.restapplication.middleware.md)


</td><td>


</td><td>

Register a middleware function or provider class


</td></tr>
<tr><td>

[mountExpressRouter(basePath, router, spec)](./rest.restapplication.mountexpressrouter.md)


</td><td>


</td><td>

Mount an Express router to expose additional REST endpoints handled via legacy Express-based stack.


</td></tr>
<tr><td>

[redirect(fromPath, toPathOrUrl, statusCode)](./rest.restapplication.redirect.md)


</td><td>


</td><td>

Register a route redirecting callers to a different URL.


</td></tr>
<tr><td>

[route(verb, path, spec, controllerCtor, controllerFactory, methodName)](./rest.restapplication.route.md)


</td><td>


</td><td>

Register a new Controller-based route.


</td></tr>
<tr><td>

[route(verb, path, spec, handler)](./rest.restapplication.route_1.md)


</td><td>


</td><td>

Register a new route invoking a handler function.


</td></tr>
<tr><td>

[route(route)](./rest.restapplication.route_2.md)


</td><td>


</td><td>

Register a new route.


</td></tr>
<tr><td>

[route(verb, path, spec, handler)](./rest.restapplication.route_3.md)


</td><td>


</td><td>

Register a new route.


</td></tr>
<tr><td>

[sequence(sequence)](./rest.restapplication.sequence.md)


</td><td>


</td><td>


</td></tr>
<tr><td>

[server(server, name)](./rest.restapplication.server.md)


</td><td>


</td><td>


</td></tr>
<tr><td>

[static(path, rootDir, options)](./rest.restapplication.static.md)


</td><td>


</td><td>

Mount static assets to the REST server. See https://expressjs.com/en/4x/api.html\#express.static


</td></tr>
</tbody></table>

