Basically, create a set of functions in NodeJS to use the Plone rest API. These functions can always be reused.
By modular, I meant that these functions should be built only to serve the required purpose.
These functions should be built in such way that they are easily composable. ie. the functions should return all the required information such that if a callback function is passed to a function, it should be able to proceed.
for eg. Consider this weird example.
Say there is a function
F1() which returns a few posts and once you get the result in
F1() you want to save next batch (if it exists) in an internal cache. (
F1() is asynchronous)
One way to do this is to use
await, check if next batch exists and continue with the workflow.
Another way is to pass a callback function, which should execute within
F1(), once it is done.
I prefer the latter. This callback function should have enough information to proceed.
(This is a pretty dumb example, I’ll notify you once I come up with a better one.)
This callback function could be one of the functions we built, so this is what I meant by composable, The functions should be built in such a way that you can chain callback functions.
The advantage with the latler design is that, the context of the previus executions is available to the currently executing function, this could be used in a productive way.
I might have used the wrong word there, Am sorry for any misunderstanding.