What are bindings?
Last updated
Was this helpful?
Last updated
Was this helpful?
This project and documentation are work in progress
Bindings take a library that has been instantiated with adapters, and expose it to the outside world. In the case of the example project, our binding is a REST HTTP interface, but you could write a binding to support GraphQL, pub/sub events, or even commands from a user interface (like in a CLI app).
To make the community library app into a webservice, I've written an Express.js binding that maps library functions to incoming HTTP calls:
the fn from the library to call
a function that validates the input into the format expected
a function to extract input from Express' Request
object
a function for handling success and responding with the right status code
The example route function also manages validation failure and how to log and respond to exceptions.
The Route
function is defined in and takes an object with four fields: