Page Contents

Home > @loopback/rest

rest package

@loopback/rest

Classes

Class Description
BaseRoute Base implementation of RouteEntry
BindElementProvider  
ControllerRoute A route backed by a controller
DefaultSequence The default implementation of SequenceHandler.
FindRouteProvider  
GetFromContextProvider  
HttpHandler  
InvokeMethodProvider  
JsonBodyParser  
LogErrorProvider  
ParseParamsProvider Provides the function for parsing args in requests at runtime.
RawBodyParser Parsing the request body into Buffer
RedirectRoute  
RegExpRouter Router implementation based on regexp matching
RejectProvider  
RequestBodyParser  
RequestContext A per-request Context combining an IoC container with handler context (request, response, etc.).
RestApplication 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.
RestComponent  
RestServer A REST API server for use with Loopback. Add this server to your application by importing the RestComponent.
Route  
RoutingTable Routing table
SendProvider Provides the function that populates the response object with the results of the operation.
StreamBodyParser A special body parser to retain request stream as is. It will be used by explicitly setting x-parser to 'stream' in the request body spec.
TextBodyParser  
Trie An implementation of trie for routes. The key hierarchy is built with parts of the route path delimited by /
TrieRouter Router implementation based on trie
UrlEncodedBodyParser  

Functions

Function Description
assignRouterSpec(target, additions)  
compareRoute(route1, route2) Compare two routes by verb/path for sorting
createBodyParserBinding(parserClass, key) Create a binding for the given body parser class
createControllerFactoryForBinding(key) Create a controller factory function for a given binding key
createControllerFactoryForClass(controllerCtor) Create a controller factory function for a given class
createControllerFactoryForInstance(controllerInst) Create a controller factory function for a given instance
createResolvedRoute(route, pathParams)  
getPathVariables(path) Get all path variables. For example, /root/{foo}/bar => ['foo']
parseJson(text, reviver)  
parseOperationArgs(request, route, requestBodyParser, options) Parses the request to derive arguments to be passed in for the Application controller method
rebaseOpenApiSpec(spec, basePath)  
sanitizeJsonParse(reviver) Factory to create a reviver function for JSON.parse to sanitize keys
toExpressPath(path) Convert an OpenAPI path to Express (path-to-regexp) style
validateApiPath(path) Validate the path to be compatible with OpenAPI path template. No parameter modifier, custom pattern, or unnamed parameter is allowed.
validateRequestBody(body, requestBodySpec, globalSchemas, options) Check whether the request body is valid according to the provided OpenAPI schema. The JSON schema is generated from the OpenAPI schema which is typically defined by @requestBody(). The validation leverages AJV schema validator.
writeResultToResponse(response, result) Writes the result from Application controller method into the HTTP response

Interfaces

Interface Description
ApiExplorerOptions  
BodyParser Interface to be implemented by body parser extensions
HandlerContext An object holding HTTP request, response and other data needed to handle an incoming HTTP request.
HttpServerLike  
Node A Node in the trie
OpenApiSpecForm The form of OpenAPI specs to be served
OpenApiSpecOptions Options to customize how OpenAPI specs are served
RequestBodyParserOptions Options for request body parsing See https://github.com/expressjs/body-parser/#optionsBuilt-in parsers retrieve their own options from the request body parser options. The parser specific properties override common ones.
RequestBodyValidationOptions Options for request body validation using AJV
ResolvedNode  
ResolvedRoute A route with path parameters resolved
RestRouter  
RestServerResolvedOptions  
RouteEntry An entry in the routing table
SequenceHandler A sequence handler is a class implementing sequence of actions required to handle an incoming request.

Namespaces

Namespace Description
RestBindings RestServer-specific bindings
RestHttpErrors  

Variables

Variable Description
ERR_NO_MULTI_SERVER  
REQUEST_BODY_PARSER_TAG Binding tag for request body parser extensions
SequenceActions  

Type Aliases

Type Alias Description
BindElement  
BodyParserFunction Plain function for body parsing
ControllerClass Controller class
ControllerFactory A factory function to create controller instances synchronously or asynchronously
ControllerInstance  
ExpressRequestHandler  
FindRoute Find a route matching the incoming request. Throw an error when no route was found.
GetFromContext  
HttpRequestListener  
InvokeMethod Invokes a method defined in the Application Controller
LogError Log information about a failed request.
NodeWithValue  
OperationArgs  
OperationRetval Return value of a controller method (a function implementing an operation). This is a type alias for “any”, used to distinguish operation results from other “any” typed values.
ParseParams  
PathParameterValues  
Reject Reject the request with an error.
RequestBody Request body with metadata
RestComponentConfig  
RestRouterOptions  
RestServerConfig Valid configuration for the RestServer constructor.
RestServerOptions RestServer options
RestServerResolvedConfig  
RouterSpec  
SchemaValidatorCache Cache for AJV schema validators
Send Send the operation response back to the client.
SequenceFunction A sequence function is a function implementing a custom sequence of actions to handle an incoming request.