You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A detailed list of the features and functions provided by the application router extension API.
The application router extension API enables you to create new instances of the application router, manage the approuter instance, and insert middleware using the Node.js “connect” framework. This section contains detailed information about the following areas:
The application router uses the “Connect” framework for the insertion of middleware components. You can reuse all connect middleware within the application router directly.
Approuter Extension API Functions
approuter()
Creates a new instance of the application router
first
Defines a “middleware slot” (a slot for the insertion of middleware) immediately after the connect application is created, and before any application router middleware
Tip:
This is a good place to insert infrastructure logic, for example, logging and monitoring.
beforeRequestHandler
Defines a “middleware slot” before the standard application router request handling, that is; static resource serving or forwarding to destinations.
Tip:
This is a good place to handle custom REST API requests.
beforeErrorHandler
Defines a “middleware slot” before the standard application router error handling
Tip:
This is a good place to capture or customize error handling.
start(options, callback)
Starts the application router with the given options.
options this argument is optional. If provided, it should be an object which can have any of the following properties:
port - a TCP port the application router will listen to (string, optional)
workingDir - the working directory for the application router, should contain the xs-app.json file (string, optional)
extensions - an array of extensions, each one is an object as defined in Application Router Extensions (optional)
xsappConfig - An object representing the content which is usually put in xs-app.json file. If this property is present it will take precedence over the content of xs-app.json.
callback - optional function with signature callback(err). It is invoked when the application router has started or an error has occurred. If not provided and an error occurs (for example the port is busy), the application will abort.
close(callback)
Stops the application router.
callback - optional function with signature callback(err). It is invoked when the application router has stopped or an error has occurred.