@meridianjs/framework 0.1.3 → 0.1.5
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 +9 -10
- package/dist/index.js +17 -18
- package/package.json +1 -1
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.
|
|
29
|
-
* 5.
|
|
30
|
-
* 6.
|
|
31
|
-
* 7. Load
|
|
32
|
-
* 8.
|
|
33
|
-
* 9.
|
|
34
|
-
* 10. Load
|
|
35
|
-
* 11. Load
|
|
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
|
|
|
@@ -160,7 +159,7 @@ declare function loadLinks(container: MeridianContainer, linksDir: string): Prom
|
|
|
160
159
|
* - relative local path: "./src/plugins/my-plugin"
|
|
161
160
|
* - absolute path: "/absolute/path/to/plugin"
|
|
162
161
|
*/
|
|
163
|
-
declare function loadPlugins(container: MeridianContainer, plugins: PluginConfig[], rootDir: string): Promise<void>;
|
|
162
|
+
declare function loadPlugins(container: MeridianContainer, plugins: PluginConfig[], rootDir: string, server?: any): Promise<void>;
|
|
164
163
|
|
|
165
164
|
declare class ConsoleLogger implements ILogger {
|
|
166
165
|
private readonly prefix;
|
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;
|
|
@@ -398,7 +401,7 @@ var QueryService = class {
|
|
|
398
401
|
};
|
|
399
402
|
|
|
400
403
|
// src/plugin-loader.ts
|
|
401
|
-
async function loadPlugins(container, plugins, rootDir) {
|
|
404
|
+
async function loadPlugins(container, plugins, rootDir, server) {
|
|
402
405
|
const logger = container.resolve("logger");
|
|
403
406
|
for (const plugin of plugins) {
|
|
404
407
|
logger.info(`Loading plugin: ${plugin.resolve}`);
|
|
@@ -441,17 +444,12 @@ async function loadPlugins(container, plugins, rootDir) {
|
|
|
441
444
|
}
|
|
442
445
|
}
|
|
443
446
|
if (scanRoot) {
|
|
444
|
-
await autoScanPlugin(scanRoot, container, logger);
|
|
447
|
+
await autoScanPlugin(scanRoot, container, logger, server);
|
|
445
448
|
}
|
|
446
449
|
logger.info(`Plugin loaded: ${plugin.resolve}`);
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
|
-
async function autoScanPlugin(scanRoot, container, logger) {
|
|
450
|
-
let server = null;
|
|
451
|
-
try {
|
|
452
|
-
server = container.resolve("server");
|
|
453
|
-
} catch {
|
|
454
|
-
}
|
|
452
|
+
async function autoScanPlugin(scanRoot, container, logger, server) {
|
|
455
453
|
const candidates = [
|
|
456
454
|
scanRoot,
|
|
457
455
|
// pluginRoot already points to compiled dir
|
|
@@ -464,16 +462,17 @@ async function autoScanPlugin(scanRoot, container, logger) {
|
|
|
464
462
|
const apiDir = path7.join(candidate, "api");
|
|
465
463
|
try {
|
|
466
464
|
await fs5.access(apiDir);
|
|
467
|
-
await Promise.all([
|
|
468
|
-
server ? loadRoutes(server, container, apiDir) : Promise.resolve(),
|
|
469
|
-
loadSubscribers(container, path7.join(candidate, "subscribers")),
|
|
470
|
-
loadJobs(container, path7.join(candidate, "jobs")),
|
|
471
|
-
loadLinks(container, path7.join(candidate, "links"))
|
|
472
|
-
]);
|
|
473
|
-
logger.debug(`Plugin auto-scanned from: ${candidate}`);
|
|
474
|
-
return;
|
|
475
465
|
} catch {
|
|
466
|
+
continue;
|
|
476
467
|
}
|
|
468
|
+
await Promise.all([
|
|
469
|
+
server ? loadRoutes(server, container, apiDir) : Promise.resolve(),
|
|
470
|
+
loadSubscribers(container, path7.join(candidate, "subscribers")),
|
|
471
|
+
loadJobs(container, path7.join(candidate, "jobs")),
|
|
472
|
+
loadLinks(container, path7.join(candidate, "links"))
|
|
473
|
+
]);
|
|
474
|
+
logger.debug(`Plugin auto-scanned from: ${candidate}`);
|
|
475
|
+
return;
|
|
477
476
|
}
|
|
478
477
|
logger.debug(`No api/ directory found for plugin scan root: ${scanRoot}`);
|
|
479
478
|
}
|
|
@@ -622,11 +621,11 @@ async function bootstrap(opts) {
|
|
|
622
621
|
};
|
|
623
622
|
container.register({ eventBus });
|
|
624
623
|
}
|
|
625
|
-
await loadPlugins(container, config.plugins ?? [], rootDir);
|
|
626
|
-
await loadLinks(container, path8.join(rootDir, "src", "links"));
|
|
627
624
|
const server = createServer(container, config);
|
|
628
625
|
container.register({ server });
|
|
629
626
|
await loadMiddlewares(server, container, path8.join(rootDir, "src", "api"));
|
|
627
|
+
await loadPlugins(container, config.plugins ?? [], rootDir, server);
|
|
628
|
+
await loadLinks(container, path8.join(rootDir, "src", "links"));
|
|
630
629
|
await loadRoutes(server, container, path8.join(rootDir, "src", "api"));
|
|
631
630
|
await loadSubscribers(container, path8.join(rootDir, "src", "subscribers"));
|
|
632
631
|
await loadJobs(container, path8.join(rootDir, "src", "jobs"));
|
package/package.json
CHANGED