We are using directory-tree npm to read all the directories and sub directories(subdirectories having 15000 multiple subdirectories)
Used Code:
const dirTree = require("directory-tree");
const allDirectories = dirTree('./test'); //It is taking 30minutes time to read all subdirectories
we need to show all the directories and subdirectories within 10s otherwise i have to terminated current http request and show timeout error.
The result : if the request taking more then 10s throw error
like, res.send({msg:"Reading all the directories taking too much time."});
Thanks
You can run the code once with all the information about the tree structure and save it in some .txt file. Whenever you add/delete/update directories and subdirectories you also make an edit to this new .txt file. So you can return the contents of .txt files within the 10 seconds.