UNPKG

@loopback/docs

Version:
55 lines (40 loc) 3.33 kB
--- lang: en title: 'API docs: rest.restapplication' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar 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. <b>Signature:</b> ```typescript export declare class RestApplication extends Application implements HttpServerLike ``` ## Constructors | Constructor | Modifiers | Description | | --- | --- | --- | | [(constructor)(config)](./rest.restapplication._constructor_.md) | | Constructs a new instance of the <code>RestApplication</code> class | ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [requestHandler](./rest.restapplication.requesthandler.md) | | <code>HttpRequestListener</code> | Handle incoming HTTP(S) request by invoking the corresponding Controller method via the configured Sequence. | | [restServer](./rest.restapplication.restserver.md) | | <code>RestServer</code> | The main REST server instance providing REST API for this application. | ## Methods | Method | Modifiers | Description | | --- | --- | --- | | [api(spec)](./rest.restapplication.api.md) | | 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). | | [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 | | [handler(handlerFn)](./rest.restapplication.handler.md) | | | | [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 |