Load subfolders
See original GitHub issue🚀 Feature Proposal
Given the tree:
- folder
- file a
- folder lv 1
- file b
- folder lv 2
- file c
Only the file a
is loaded and the other directories are ignored
In this example, I would register
every folder and put all the files in the same context.
Motivation
This lets the user organize the application in a more flexible structure where the URLs (except some prefix-override) is mapped to the project tree
Example
fastify.register(require('fastify-autoload'), {
dir: x,
recursive: true // as rm -rf 😅
})
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:14 (12 by maintainers)
Top Results From Across the Web
How to load all data files of all subfolders ? - MATLAB Answers
I save my data files in multiple subfolders of one folder. The one data folder (containing the subfolders) and the Matlab script to...
Read more >Loading files from multiple subfolders with in same folder
I would like to load all the csv files (50X40 = 200 files) from subfolders and combined them in to single file in...
Read more >Load data from SubFolders - Microsoft Power BI Community
i have subfolders in my data storage by fiscal year and every folder has report with "Filename + saved date" and tab are...
Read more >How to load data (images) from different folders and ...
The subfolder in GT has 3 subfolders in it out of which subfolder softmap has two images that I need to load these...
Read more >Assembly Load Option, Current Folder and Sub-Folders
While loading assemblies, we get 3 options, is there a way to change the behavior of NX to also search in sub-folders when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve implemented something similar: https://github.com/SkeLLLa/fastify-autoload-recursive some time ago. Feel free to reuse the code if you’d like.
And here some notes that I’ve found during implementing it:
Sometimes it’s useful to define file order in which they are registered. For example if we have plugin that adds shared shema and plugin that adds route in the same folder, then schema should be registered before. So that’s why I created 3 patterns for files:
schema
,options
,ignore
. Options file contains a function that may return additional options (that could be calculated dynamically, so you couldn’t pass them directly) and after that they are merged with static options and passed toregister
function. Such files evaluated in first place. Schema files contain shared schemas that are used later. Such files are registered before other files, so later we can use shared shemas. Ignore patter is used to ignore files, for example, some helpers with common code that are used only in specific plugin or service. Those are ignored by autoloader and required directly in other files.I don’t know if
schema
andoptions
settings are useful for others, but I think that ignore pattern (for files and folders as well) here is a must have feature for recursive loading.If you don’t mind I’ll try to do it. Good part of being at home 😅 having time for open source