@meridianjs/framework 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -25,15 +25,14 @@ interface MeridianApp {
25
25
  * 1. Load meridian.config.ts
26
26
  * 2. Create global DI container
27
27
  * 3. Register core primitives (logger, config)
28
- * 4. Register infrastructure modules (event bus, scheduler)
29
- * 5. Load domain modules from config.modules[]
30
- * 6. Load plugins from config.plugins[]
31
- * 7. Load module links from src/links/
32
- * 8. Create Express server
33
- * 9. Apply middlewares from src/api/middlewares.ts
34
- * 10. Load file-based API routes from src/api/
35
- * 11. Load subscribers from src/subscribers/
36
- * 12. Load scheduled jobs from src/jobs/
28
+ * 4. Load modules from config.modules[]
29
+ * 5. Create Express server (registered before plugins so they can add routes)
30
+ * 6. Apply middlewares from src/api/middlewares.ts
31
+ * 7. Load plugins from config.plugins[]
32
+ * 8. Load module links from src/links/
33
+ * 9. Load file-based API routes from src/api/
34
+ * 10. Load subscribers from src/subscribers/
35
+ * 11. Load scheduled jobs from src/jobs/
37
36
  */
38
37
  declare function bootstrap(opts: BootstrapOptions): Promise<MeridianApp>;
39
38
 
package/dist/index.js CHANGED
@@ -241,6 +241,7 @@ async function loadSubscribers(container, subscribersDir) {
241
241
  const eventBus = container.resolve("eventBus");
242
242
  const files = await fs2.readdir(subscribersDir);
243
243
  for (const file of files) {
244
+ if (/\.d\.(ts|mts)$/.test(file)) continue;
244
245
  if (!/\.(ts|mts|js|mjs|cjs)$/.test(file)) continue;
245
246
  const fullPath = path4.join(subscribersDir, file);
246
247
  let mod;
@@ -292,6 +293,7 @@ async function loadJobs(container, jobsDir) {
292
293
  }
293
294
  const files = await fs3.readdir(jobsDir);
294
295
  for (const file of files) {
296
+ if (/\.d\.(ts|mts)$/.test(file)) continue;
295
297
  if (!/\.(ts|mts|js|mjs|cjs)$/.test(file)) continue;
296
298
  const fullPath = path5.join(jobsDir, file);
297
299
  let mod;
@@ -332,6 +334,7 @@ async function loadLinks(container, linksDir) {
332
334
  }
333
335
  const files = await fs4.readdir(linksDir);
334
336
  for (const file of files) {
337
+ if (/\.d\.(ts|mts)$/.test(file)) continue;
335
338
  if (!/\.(ts|mts|js|mjs|cjs)$/.test(file)) continue;
336
339
  const fullPath = path6.join(linksDir, file);
337
340
  let mod;
@@ -447,7 +450,11 @@ async function loadPlugins(container, plugins, rootDir) {
447
450
  }
448
451
  }
449
452
  async function autoScanPlugin(scanRoot, container, logger) {
450
- const server = container.resolve("server");
453
+ let server = null;
454
+ try {
455
+ server = container.resolve("server");
456
+ } catch {
457
+ }
451
458
  const candidates = [
452
459
  scanRoot,
453
460
  // pluginRoot already points to compiled dir
@@ -460,16 +467,17 @@ async function autoScanPlugin(scanRoot, container, logger) {
460
467
  const apiDir = path7.join(candidate, "api");
461
468
  try {
462
469
  await fs5.access(apiDir);
463
- await Promise.all([
464
- loadRoutes(server, container, apiDir),
465
- loadSubscribers(container, path7.join(candidate, "subscribers")),
466
- loadJobs(container, path7.join(candidate, "jobs")),
467
- loadLinks(container, path7.join(candidate, "links"))
468
- ]);
469
- logger.debug(`Plugin auto-scanned from: ${candidate}`);
470
- return;
471
470
  } catch {
471
+ continue;
472
472
  }
473
+ await Promise.all([
474
+ server ? loadRoutes(server, container, apiDir) : Promise.resolve(),
475
+ loadSubscribers(container, path7.join(candidate, "subscribers")),
476
+ loadJobs(container, path7.join(candidate, "jobs")),
477
+ loadLinks(container, path7.join(candidate, "links"))
478
+ ]);
479
+ logger.debug(`Plugin auto-scanned from: ${candidate}`);
480
+ return;
473
481
  }
474
482
  logger.debug(`No api/ directory found for plugin scan root: ${scanRoot}`);
475
483
  }
@@ -618,11 +626,11 @@ async function bootstrap(opts) {
618
626
  };
619
627
  container.register({ eventBus });
620
628
  }
621
- await loadPlugins(container, config.plugins ?? [], rootDir);
622
- await loadLinks(container, path8.join(rootDir, "src", "links"));
623
629
  const server = createServer(container, config);
624
630
  container.register({ server });
625
631
  await loadMiddlewares(server, container, path8.join(rootDir, "src", "api"));
632
+ await loadPlugins(container, config.plugins ?? [], rootDir);
633
+ await loadLinks(container, path8.join(rootDir, "src", "links"));
626
634
  await loadRoutes(server, container, path8.join(rootDir, "src", "api"));
627
635
  await loadSubscribers(container, path8.join(rootDir, "src", "subscribers"));
628
636
  await loadJobs(container, path8.join(rootDir, "src", "jobs"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meridianjs/framework",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Core Meridian framework: bootstrap, DI container, module/route/subscriber/job loaders",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",