A routes.js file allows a developer to host REST API routes on the XIBLE API endpoint.
Since XIBLE exposes an express.js router, their docs are applicable here.
URL
Internally, every node saved in a flow gets its own _id parameter. This _id is key to where the node API router is hosted;
/api/node-routes/${NODE._id}/
routes.js
'use strict';
// export a function to run when XIBLE starts
module.exports = (NODE, ROUTER) => {
// setup a simple GET route
ROUTER.get('/hello', (req, res) => {
res.json({ hello: 'world' });
});
// handle some input
ROUTER.put('/data', (req, res) => {
// store the data in the vault
// this will now be available in the node through NODE.data.data
NODE.vault.set({ data: req.body.data });
res.end();
});
};