You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -288,6 +325,148 @@ Configure default behaviors for modules.
288
325
-`DEFAULT_RATE_LIMIT_REQUESTS` or `MORO_RATE_LIMIT_REQUESTS`
289
326
-`DEFAULT_RATE_LIMIT_WINDOW` or `MORO_RATE_LIMIT_WINDOW`
290
327
-`VALIDATION_ENABLED` or `MORO_VALIDATION_ENABLED`
328
+
-`AUTO_DISCOVERY_ENABLED` or `MORO_AUTO_DISCOVERY_ENABLED`
329
+
-`AUTO_DISCOVERY_PATHS` or `MORO_AUTO_DISCOVERY_PATHS` (comma-separated)
330
+
-`AUTO_DISCOVERY_PATTERNS` or `MORO_AUTO_DISCOVERY_PATTERNS` (comma-separated)
331
+
-`AUTO_DISCOVERY_LOADING_STRATEGY` or `MORO_AUTO_DISCOVERY_LOADING_STRATEGY`
332
+
-`AUTO_DISCOVERY_WATCH_FOR_CHANGES` or `MORO_AUTO_DISCOVERY_WATCH_FOR_CHANGES`
333
+
-`AUTO_DISCOVERY_LOAD_ORDER` or `MORO_AUTO_DISCOVERY_LOAD_ORDER`
334
+
-`AUTO_DISCOVERY_FAIL_ON_ERROR` or `MORO_AUTO_DISCOVERY_FAIL_ON_ERROR`
335
+
-`AUTO_DISCOVERY_MAX_DEPTH` or `MORO_AUTO_DISCOVERY_MAX_DEPTH`
336
+
337
+
## Auto-Discovery Configuration
338
+
339
+
MoroJS includes a powerful auto-discovery system that automatically finds and loads modules from your filesystem. This system supports multiple loading strategies, dependency resolution, and hot reloading for development.
340
+
341
+
### Basic Usage
342
+
343
+
```javascript
344
+
// Simple auto-discovery
345
+
constapp=createApp({
346
+
autoDiscover:true// Use defaults
347
+
});
348
+
349
+
// Advanced configuration
350
+
constapp=createApp({
351
+
autoDiscover: {
352
+
enabled:true,
353
+
paths: ['./modules', './src/modules'],
354
+
loadingStrategy:'lazy',
355
+
watchForChanges:true// Development only
356
+
}
357
+
});
358
+
```
359
+
360
+
### Legacy Compatibility
361
+
362
+
```javascript
363
+
// Legacy modulesPath (still supported)
364
+
constapp=createApp({
365
+
modulesPath:'./modules'// Equivalent to autoDiscover.paths: ['./modules']
366
+
});
367
+
```
368
+
369
+
### Loading Strategies
370
+
371
+
#### Eager Loading (Default)
372
+
All modules are loaded immediately during application startup.
373
+
374
+
```javascript
375
+
{
376
+
autoDiscover: {
377
+
loadingStrategy:'eager'
378
+
}
379
+
}
380
+
```
381
+
382
+
#### Lazy Loading
383
+
Modules are loaded on first request to their routes.
384
+
385
+
```javascript
386
+
{
387
+
autoDiscover: {
388
+
loadingStrategy:'lazy'
389
+
}
390
+
}
391
+
```
392
+
393
+
#### Conditional Loading
394
+
Modules are loaded based on environment or feature flags.
395
+
396
+
```javascript
397
+
{
398
+
autoDiscover: {
399
+
loadingStrategy:'conditional'
400
+
}
401
+
}
402
+
```
403
+
404
+
### Development Features
405
+
406
+
#### Hot Reloading
407
+
Enable file watching for automatic module reloading during development:
0 commit comments