Page Contents

Home > @loopback/rest > RestApplication

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.


export declare class RestApplication extends Application implements HttpServerLike 


Constructor Modifiers Description
(constructor)(parent)   Create a REST application with the given parent context
(constructor)(config, parent)   Create a REST application with the given configuration and parent context


Method Modifiers Description
api(spec)   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)   Configure the basePath for the rest server
bodyParser(bodyParserClass, address)   Bind a body parser to the server context
mountExpressRouter(basePath, router, spec)   Mount an Express router to expose additional REST endpoints handled via legacy Express-based stack.
redirect(fromPath, toPathOrUrl, statusCode)   Register a route redirecting callers to a different URL.
route(verb, path, spec, controllerCtor, controllerFactory, methodName)   Register a new Controller-based route.
route(verb, path, spec, handler)   Register a new route invoking a handler function.
route(route)   Register a new route.
route(verb, path, spec, handler)   Register a new route.
server(server, name)    
static(path, rootDir, options)   Mount static assets to the REST server. See