rest package
The REST API package for loopback-next.
Remarks
A REST server for LoopBack 4 application instances, complete with:
- new custom routing engine (special thanks to @bajtos)! - tools for defining your application routes - OpenAPI 3.0 spec (openapi.json/openapi.yaml) generation using @loopback/openapi-v3 - a default sequence implementation to manage the request and response lifecycle
Classes
| Class | Description |
|---|---|
|
A route backed by a controller | |
|
The default implementation of SequenceHandler. | |
|
An OpenAPI spec enhancer to populate | |
|
A sequence implementation using middleware chains | |
|
Provides the function for parsing args in requests at runtime. | |
|
Parsing the request body into Buffer | |
|
Router implementation based on regexp matching | |
|
A per-request Context combining an IoC container with handler context (request, response, etc.). | |
|
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. | |
|
A REST API server for use with Loopback. Add this server to your application by importing the RestComponent. | |
|
Routing table | |
|
Provides the function that populates the response object with the results of the operation. | |
|
A special body parser to retain request stream as is. It will be used by explicitly setting | |
|
An implementation of trie for routes. The key hierarchy is built with parts of the route path delimited by | |
|
Router implementation based on trie | |
Abstract Classes
| Abstract Class | Description |
|---|---|
|
Base implementation of RouteEntry |
Functions
| Function | Description |
|---|---|
|
Compare two routes by verb/path for sorting | |
|
Create a binding for the given body parser class | |
|
Create a controller factory function for a given binding key | |
|
Create a controller factory function for a given class | |
|
Create a controller factory function for a given instance | |
|
createRoutesForController(spec, controllerCtor, controllerFactory) |
Create routes for a controller with the given spec |
|
Get the content-type header value from the request | |
|
Extract parser options based on the parser type | |
|
Get all path variables. For example, | |
|
Parse the request body asynchronously | |
|
Normalize parsing errors as | |
|
Parse a json string that rejects prohibited keys | |
|
parseOperationArgs(request, route, requestBodyParser, options) |
Parses the request to derive arguments to be passed in for the Application controller method |
|
Factory to create a reviver function for | |
|
Convert an OpenAPI path to Express (path-to-regexp) style | |
|
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 |
|
validateValueAgainstSchema(value, schema, globalSchemas, options) |
Validate the value against JSON schema. |
|
Writes the result from Application controller method into the HTTP response |
Interfaces
| Interface | Description |
|---|---|
|
Interface to be implemented by body parser extensions | |
|
A Node in the trie | |
|
The form of OpenAPI specs to be served | |
|
Options to customize how OpenAPI specs are served | |
|
Options for request body parsing See https://github.com/expressjs/body-parser/#options Built-in parsers retrieve their own options from the request body parser options. The parser specific properties override common ones. | |
|
extending express request type with a session field | |
|
A route with path parameters resolved | |
|
An entry in the routing table | |
|
A sequence handler is a class implementing sequence of actions required to handle an incoming request. | |
|
interface to set variables in user session | |
|
user profile to add in session | |
|
Options for request body validation using AJV | |
|
Options for any value validation using AJV |
Namespaces
| Namespace | Description |
|---|---|
|
RestServer-specific bindings | |
|
Built-in middleware groups for the REST sequence | |
|
Binding tags for RestServer |
Variables
| Variable | Description |
|---|---|
|
Binding tag for request body parser extensions | |
Type Aliases
| Type Alias | Description |
|---|---|
|
Options for AJV errors | |
|
Factory function for Ajv instances | |
|
Ajv format definition with a name | |
|
Ajv keyword definition with a name | |
|
Plain function for body parsing | |
|
Express body parser function type | |
|
Controller class | |
|
A factory function to create controller instances synchronously or asynchronously | |
|
Find a route matching the incoming request. Throw an error when no route was found. | |
|
Invokes a method defined in the Application Controller | |
|
Log information about a failed request. | |
|
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. | |
|
A function to parse OpenAPI operation parameters for a given route | |
|
Reject the request with an error. | |
|
Request body with metadata | |
|
Valid configuration for the RestServer constructor. | |
|
RestServer options | |
|
Cache for AJV schema validators | |
|
Send the operation response back to the client. | |
|
A sequence function is a function implementing a custom sequence of actions to handle an incoming request. |