nuxt-generation-emails 1.4.4 → 1.4.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/README.md CHANGED
@@ -288,6 +288,8 @@ The `components/` directory is reserved — it is skipped during route generatio
288
288
 
289
289
  For API endpoints, nested `index.vue` files are treated as directory index routes, so the trailing `/index` is removed. Root-level `emails/index.vue` keeps the existing endpoint: `POST /api/emails/index`.
290
290
 
291
+ If both `emails/foo.vue` and `emails/foo/index.vue` exist, the nested file keeps `POST /api/emails/foo/index` to avoid route collisions and preserve OpenAPI examples/schema for both handlers.
292
+
291
293
  ---
292
294
 
293
295
  ## Sending Emails
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "1.4.4",
7
+ "version": "1.4.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -762,10 +762,15 @@ function sanitizeForOpenApi(value) {
762
762
  }
763
763
  return value;
764
764
  }
765
- function normalizeApiEmailPath(routePrefix, emailName) {
765
+ function normalizeApiEmailPath(emailsDir, routePrefix, emailName) {
766
766
  const rawPath = `${routePrefix}/${emailName}`.replace(/^\//, "");
767
767
  if (emailName === "index" && routePrefix) {
768
- return routePrefix.replace(/^\//, "");
768
+ const indexlessPath = routePrefix.replace(/^\//, "");
769
+ const siblingTemplatePath = join(emailsDir, `${indexlessPath}.vue`);
770
+ if (fs.existsSync(siblingTemplatePath)) {
771
+ return rawPath;
772
+ }
773
+ return indexlessPath;
769
774
  }
770
775
  return rawPath;
771
776
  }
@@ -788,7 +793,7 @@ function generateServerRoutes(emailsDir, buildDir) {
788
793
  processEmailDirectory(fullPath, `${routePrefix}/${entry}`);
789
794
  } else if (entry.endsWith(".vue")) {
790
795
  const emailName = entry.replace(".vue", "");
791
- const emailPath = normalizeApiEmailPath(routePrefix, emailName);
796
+ const emailPath = normalizeApiEmailPath(emailsDir, routePrefix, emailName);
792
797
  const mjmlTemplateName = extractMjmlTemplateName(fullPath);
793
798
  if (!mjmlTemplateName) {
794
799
  console.warn(`[nuxt-generation-emails] Could not find useNgeTemplate() call in ${emailName}.vue \u2014 skipping API route.`);
@@ -805,7 +810,8 @@ function generateServerRoutes(emailsDir, buildDir) {
805
810
  }
806
811
  const { defaults } = extractPropsFromSFC(fullPath);
807
812
  const sanitized = sanitizeForOpenApi(defaults);
808
- const examplePayload = Object.keys(sanitized).length > 0 ? JSON.stringify(sanitized, null, 2) : "{}";
813
+ const sanitizedDefaults = sanitized && typeof sanitized === "object" && !Array.isArray(sanitized) ? sanitized : {};
814
+ const examplePayload = Object.keys(sanitizedDefaults).length > 0 ? JSON.stringify(sanitizedDefaults, null, 2) : "{}";
809
815
  const handlerFileName = `${emailName}.ts`;
810
816
  const handlerFilePath = join(handlerDir, handlerFileName);
811
817
  const handlerContent = generateApiRoute(emailName, emailPath, examplePayload, mjmlTemplateName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-generation-emails",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "A Nuxt module for authoring, previewing, and sending transactional email templates with MJML and Handlebars.",
5
5
  "author": "nullcarry@icloud.com",
6
6
  "repository": {