@donkeylabs/cli 1.1.14 → 1.1.16
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 +1 -1
- package/templates/sveltekit-app/.env.example +3 -1
- package/templates/sveltekit-app/src/server/index.ts +43 -2
- package/templates/sveltekit-app/src/server/plugins/auth/index.ts +552 -133
- package/templates/sveltekit-app/src/server/plugins/auth/migrations/003_create_refresh_tokens.ts +33 -0
- package/templates/sveltekit-app/src/server/plugins/auth/migrations/004_create_passkeys.ts +60 -0
- package/templates/sveltekit-app/src/server/plugins/email/index.ts +411 -0
- package/templates/sveltekit-app/src/server/plugins/email/migrations/001_create_email_tokens.ts +33 -0
- package/templates/sveltekit-app/src/server/routes/auth/auth.schemas.ts +15 -1
- package/templates/sveltekit-app/src/server/routes/auth/handlers/login.handler.ts +2 -2
- package/templates/sveltekit-app/src/server/routes/auth/handlers/logout.handler.ts +5 -5
- package/templates/sveltekit-app/src/server/routes/auth/handlers/refresh.handler.ts +19 -0
- package/templates/sveltekit-app/src/server/routes/auth/handlers/register.handler.ts +1 -1
- package/templates/sveltekit-app/src/server/routes/auth/index.ts +13 -2
package/package.json
CHANGED
|
@@ -33,8 +33,10 @@ NODE_ENV=development
|
|
|
33
33
|
# EXTERNAL SERVICES (examples)
|
|
34
34
|
# =============================================================================
|
|
35
35
|
|
|
36
|
-
# Email service (
|
|
36
|
+
# Email service (Resend)
|
|
37
37
|
# RESEND_API_KEY=re_xxxxxxxxxxxx
|
|
38
|
+
# EMAIL_FROM=noreply@yourdomain.com
|
|
39
|
+
# PUBLIC_BASE_URL=https://yourdomain.com
|
|
38
40
|
|
|
39
41
|
# Payment processing (e.g., Stripe)
|
|
40
42
|
# STRIPE_SECRET_KEY=sk_test_xxxxxxxxxxxx
|
|
@@ -6,6 +6,7 @@ import { Database } from "bun:sqlite";
|
|
|
6
6
|
import { demoPlugin } from "./plugins/demo";
|
|
7
7
|
import { workflowDemoPlugin } from "./plugins/workflow-demo";
|
|
8
8
|
import { authPlugin } from "./plugins/auth";
|
|
9
|
+
import { emailPlugin } from "./plugins/email";
|
|
9
10
|
import demoRoutes from "./routes/demo";
|
|
10
11
|
import { exampleRouter } from "./routes/example";
|
|
11
12
|
import { authRouter } from "./routes/auth";
|
|
@@ -24,8 +25,48 @@ export const server = new AppServer({
|
|
|
24
25
|
},
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
//
|
|
28
|
-
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// AUTH PLUGIN CONFIGURATION
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// Choose your auth strategy:
|
|
32
|
+
//
|
|
33
|
+
// 1. SESSION (default) - Stateful, stores sessions in database
|
|
34
|
+
// Best for: Web apps, server-rendered pages
|
|
35
|
+
// server.registerPlugin(authPlugin());
|
|
36
|
+
//
|
|
37
|
+
// 2. JWT - Stateless tokens, no database lookup needed
|
|
38
|
+
// Best for: Mobile apps, microservices, APIs
|
|
39
|
+
// server.registerPlugin(authPlugin({
|
|
40
|
+
// strategy: "jwt",
|
|
41
|
+
// jwt: { secret: process.env.JWT_SECRET! },
|
|
42
|
+
// }));
|
|
43
|
+
//
|
|
44
|
+
// 3. REFRESH-TOKEN - Short-lived access + long-lived refresh token
|
|
45
|
+
// Best for: SPAs, mobile apps needing token refresh
|
|
46
|
+
// server.registerPlugin(authPlugin({
|
|
47
|
+
// strategy: "refresh-token",
|
|
48
|
+
// jwt: {
|
|
49
|
+
// secret: process.env.JWT_SECRET!,
|
|
50
|
+
// accessExpiry: "15m",
|
|
51
|
+
// refreshExpiry: "30d",
|
|
52
|
+
// },
|
|
53
|
+
// cookie: { httpOnly: true, secure: true },
|
|
54
|
+
// }));
|
|
55
|
+
//
|
|
56
|
+
// =============================================================================
|
|
57
|
+
|
|
58
|
+
// Using default session strategy for this template
|
|
59
|
+
server.registerPlugin(authPlugin());
|
|
60
|
+
|
|
61
|
+
// Email plugin - supports Resend or console (for development)
|
|
62
|
+
// Configure with process.env.RESEND_API_KEY for production
|
|
63
|
+
server.registerPlugin(emailPlugin({
|
|
64
|
+
provider: process.env.RESEND_API_KEY ? "resend" : "console",
|
|
65
|
+
resend: process.env.RESEND_API_KEY ? { apiKey: process.env.RESEND_API_KEY } : undefined,
|
|
66
|
+
from: process.env.EMAIL_FROM || "noreply@example.com",
|
|
67
|
+
baseUrl: process.env.PUBLIC_BASE_URL || "http://localhost:5173",
|
|
68
|
+
}));
|
|
69
|
+
|
|
29
70
|
server.registerPlugin(demoPlugin);
|
|
30
71
|
server.registerPlugin(workflowDemoPlugin);
|
|
31
72
|
|