Using the Alfresco NodeJS API to create a folder path
I think my problem is a lack of understanding of Node, rather than Alfresco, but here's what I'm trying to achieve:
Given a folder path as a string e.g. /Cities/London/Stations/Euston I want to create that folder path at a give root inside Alfresco.
Using Java, one solution would be to split the folder path string at '/' then loop through each folder name creating a folder then using it as the parent for the next folder. This works because each folder is created before the code moves on to create the next folder.
The non-blocking nature of Node means if I simply put a for loop around the API call then it will fail because you cannot guarantee that the parent folders will have been created by the time Alfresco tries to create the subfolder.
I didn't have to set up the createFolder function, I could have just done lines 4 through 13 but I somehow find this easier to read.
Running this with node will create a folder named "testjs" under the root under some/path.
To answer your original question, if the path argument wasn't supported, and if you instead had to pass in a node reference or something like that for the parent, you could do the split as you suggest and then recursively call create folder.