question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🚀 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
SkeLLLacommented, Oct 7, 2019

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 to register 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 and options 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.

2reactions
alemagiocommented, Mar 24, 2020

If you don’t mind I’ll try to do it. Good part of being at home 😅 having time for open source

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found