@infuro/cms-core 1.0.0 → 1.0.1

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.cjs CHANGED
@@ -221,8 +221,12 @@ async function createCmsApp(options) {
221
221
  const context = { dataSource, config, logger };
222
222
  const registry = /* @__PURE__ */ new Map();
223
223
  for (const plugin of plugins) {
224
- const instance = await plugin.init(context);
225
- registry.set(plugin.name, instance !== void 0 ? instance : plugin);
224
+ try {
225
+ const instance = await plugin.init(context);
226
+ registry.set(plugin.name, instance !== void 0 ? instance : plugin);
227
+ } catch (err) {
228
+ logger.warn(`Plugin "${plugin.name}" failed to init: ${err instanceof Error ? err.message : err}`);
229
+ }
226
230
  }
227
231
  return {
228
232
  dataSource,
@@ -461,17 +465,26 @@ function emailPlugin(config) {
461
465
  async init(context) {
462
466
  const from = config.from || context.config.SMTP_FROM || "no-reply@example.com";
463
467
  const to = config.to || context.config.SMTP_TO || "info@example.com";
468
+ const type = config.type || context.config.SMTP_TYPE || "SMTP";
464
469
  const merged = {
465
470
  ...config,
466
471
  from,
467
472
  to,
468
- type: config.type || context.config.SMTP_TYPE || "SMTP",
473
+ type,
469
474
  user: config.user ?? context.config.SMTP_USER,
470
475
  password: config.password ?? context.config.SMTP_PASSWORD,
471
476
  region: config.region ?? context.config.AWS_REGION,
472
477
  accessKeyId: config.accessKeyId ?? context.config.AWS_ACCESS_KEY_ID,
473
478
  secretAccessKey: config.secretAccessKey ?? context.config.AWS_SECRET_ACCESS_KEY
474
479
  };
480
+ if (type === "AWS" && (!merged.region || !merged.accessKeyId || !merged.secretAccessKey)) {
481
+ context.logger.warn("Email plugin skipped: AWS SES configuration incomplete");
482
+ return void 0;
483
+ }
484
+ if ((type === "SMTP" || type === "GMAIL") && (!merged.user || !merged.password)) {
485
+ context.logger.warn("Email plugin skipped: SMTP credentials not configured");
486
+ return void 0;
487
+ }
475
488
  return new EmailService(merged);
476
489
  }
477
490
  };