DEITY Falcon provides developers with a set of base classes and modules to work with endpoints on both Falcon-Client and Falcon-Server applications.
First, you need to configure such endpoint entries. If you were configuring ApiDataSources and Extensions in Falcon-Server previously - it won't be any different from that. Add the following configuration to your Falcon-Server config:
As you can tell, endpoint handlers will be loaded from the existing
src/endpoints.js file to initialize the handlers.
The implementation part of such endpoint handlers may vary depending on your needs, but in case of
these endpoints are being proxied to the remote Magento instance, so by passing a
config object to the endpoint module -
you're telling where you want to proxy these endpoint requests to.
Endpoints on Falcon-Client
In order to proxy your endpoints to Falcon-Server from Falcon-Client app - you need to configure your
onRouterCreated hook - Falcon-Client will get a bootstrap config from Falcon-Server (including a plain list
of route patterns to be proxied from Falcon-Client to Falcon-Server applications).
EndpointContainer is a container module, which is being used by Falcon-Server to transform the provided configuration
into web-server routes and attach proper handlers. Every entry in
endpoints section must represent a configuration
package value that points to a class extended from
DEITY Falcon provides a generic proxy-endpoints helper to proxy all specified routes to the remote API server. In order to use it - you need to configure your Falcon-Server application with the following configuration:
entries should represent a list of routes (string patters) you want to proxy from Falcon-Client through Falcon-Server
to the remote API (
https://example.com in our case). The requested route won't be changed, and all the incoming
headers and payload will be passed as well.
All endpoint modules should be extended from
If you're implementing your own Endpoints package -
fetch method which allows you
to perform any HTTP requests you need.
fetchmethod is in fact an instance of
node-fetchpackage, please check its documentation for more details on how to use it.
This method is being called by
EndpointContainer when Falcon-Server initializes endpoints and passes them to
the web-server router.
getEntries() must return an array of
EndpointEntry type objects with the following structure: