---
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

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [(constructor)(parent)](./rest.restapplication._constructor_.md) |  | Create a REST application with the given parent context |
|  [(constructor)(config, parent)](./rest.restapplication._constructor__1.md) |  | Create a REST application with the given configuration and parent context |

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [requestHandler](./rest.restapplication.requesthandler.md) | <code>readonly</code> | [HttpRequestListener](./rest.httprequestlistener.md) | Handle incoming HTTP(S) request by invoking the corresponding Controller method via the configured Sequence. |
|  [restServer](./rest.restapplication.restserver.md) | <code>readonly</code> | [RestServer](./rest.restserver.md) | The main REST server instance providing REST API for this application. |

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [api(spec)](./rest.restapplication.api.md) |  | <p>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.</p><p>Note that this will override any routes defined via decorators at the controller level (this function takes precedent).</p> |
|  [basePath(path)](./rest.restapplication.basepath.md) |  | Configure the <code>basePath</code> for the rest server |
|  [bodyParser(bodyParserClass, address)](./rest.restapplication.bodyparser.md) |  | Bind a body parser to the server context |
|  [exportOpenApiSpec(outFile, log)](./rest.restapplication.exportopenapispec.md) |  | Export the OpenAPI spec to the given json or yaml file |
|  [expressMiddleware(key, middleware, options)](./rest.restapplication.expressmiddleware.md) |  | Bind an Express middleware to this server context |
|  [expressMiddleware(middlewareFactory, middlewareConfig, options)](./rest.restapplication.expressmiddleware_1.md) |  | Bind an Express middleware to this server context |
|  [handler(handlerFn)](./rest.restapplication.handler.md) |  |  |
|  [middleware(middleware, options)](./rest.restapplication.middleware.md) |  | Register a middleware function or provider class |
|  [mountExpressRouter(basePath, router, spec)](./rest.restapplication.mountexpressrouter.md) |  | Mount an Express router to expose additional REST endpoints handled via legacy Express-based stack. |
|  [redirect(fromPath, toPathOrUrl, statusCode)](./rest.restapplication.redirect.md) |  | Register a route redirecting callers to a different URL. |
|  [route(verb, path, spec, controllerCtor, controllerFactory, methodName)](./rest.restapplication.route.md) |  | Register a new Controller-based route. |
|  [route(verb, path, spec, handler)](./rest.restapplication.route_1.md) |  | Register a new route invoking a handler function. |
|  [route(route)](./rest.restapplication.route_2.md) |  | Register a new route. |
|  [route(verb, path, spec, handler)](./rest.restapplication.route_3.md) |  | Register a new route. |
|  [sequence(sequence)](./rest.restapplication.sequence.md) |  |  |
|  [server(server, name)](./rest.restapplication.server.md) |  |  |
|  [static(path, rootDir, options)](./rest.restapplication.static.md) |  | Mount static assets to the REST server. See https://expressjs.com/en/4x/api.html\#express.static |


