create-mikstack 0.1.9 → 0.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mikstack",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,9 @@
1
1
  import { createTransport } from "nodemailer";
2
+ import { desc, eq } from "drizzle-orm";
2
3
  import { dev } from "$app/environment";
3
4
  import { env } from "$env/dynamic/private";
5
+ import { db } from "../db";
6
+ import { notificationDelivery } from "../db/schema";
4
7
 
5
8
  interface Email {
6
9
  subject: string;
@@ -14,7 +17,7 @@ interface Email {
14
17
  * This is used as the transport for @mikstack/notifications emailChannel.
15
18
  * Delivery tracking (status, retries, errors) is handled by the notifications system.
16
19
  *
17
- * In dev mode, SMTP is skipped — emails are logged to the console only.
20
+ * In dev mode, SMTP is skipped — emails are logged to the console and a preview link is shown.
18
21
  *
19
22
  * The SMTP transport uses nodemailer. Easy to replace with your preferred provider:
20
23
  * - Resend: https://resend.com/docs
@@ -24,7 +27,24 @@ interface Email {
24
27
  */
25
28
  export async function sendEmail(to: string, email: Email): Promise<void> {
26
29
  if (dev) {
27
- console.log(`\n✉️ Email: "${email.subject}" ${to}\n`);
30
+ const [delivery] = await db
31
+ .select({ id: notificationDelivery.id })
32
+ .from(notificationDelivery)
33
+ .where(eq(notificationDelivery.recipientEmail, to))
34
+ .orderBy(desc(notificationDelivery.createdAt))
35
+ .limit(1);
36
+
37
+ const previewUrl = delivery
38
+ ? `http://localhost:5173/api/dev/emails/${delivery.id}`
39
+ : "http://localhost:5173/api/dev/emails";
40
+
41
+ console.log(
42
+ `\n✉️ Email: "${email.subject}" → ${to}` +
43
+ `\n${"─".repeat(60)}` +
44
+ `\n${email.text}` +
45
+ `\n${"─".repeat(60)}` +
46
+ `\n🔗 Preview: ${previewUrl}\n`,
47
+ );
28
48
  return;
29
49
  }
30
50
 
@@ -1,4 +1,4 @@
1
- import { devtoolsJson } from "vite-plugin-devtools-json";
1
+ import devtoolsJson from "vite-plugin-devtools-json";
2
2
  import { sveltekit } from "@sveltejs/kit/vite";
3
3
  import { linguiPo } from "@mikstack/svelte-lingui/vite";
4
4
  import { defineConfig } from "vite";
@@ -1,4 +1,4 @@
1
- import { devtoolsJson } from "vite-plugin-devtools-json";
1
+ import devtoolsJson from "vite-plugin-devtools-json";
2
2
  import { sveltekit } from "@sveltejs/kit/vite";
3
3
  import { defineConfig } from "vite";
4
4