feat: add subscription service — user auth, Stripe billing, API keys, dashboard
- NextAuth v5 with email+password credentials, JWT sessions - Registration, login, email verification, password reset flows - Stripe integration: Free (15/day), Starter ($5/1k/mo), Pro ($20/100k/mo) - API key management (cb_ prefix) with hash-based validation - Dashboard with generations history, settings, billing management - Rate limiting: Redis daily counter (free), DB monthly (paid) - Generate route auth: Bearer API key + session, anonymous allowed - Worker userId propagation for generation history - Pricing section on landing page, auth-aware navbar - Middleware with route protection, CORS for codeboard.vectry.tech - Docker env vars for auth, Stripe, email (smtp.migadu.com)
This commit is contained in:
36
apps/web/src/lib/email.ts
Normal file
36
apps/web/src/lib/email.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
interface SendEmailOptions {
|
||||
to: string;
|
||||
subject: string;
|
||||
html: string;
|
||||
}
|
||||
|
||||
export async function sendEmail({ to, subject, html }: SendEmailOptions) {
|
||||
const password = process.env.EMAIL_PASSWORD;
|
||||
|
||||
if (!password) {
|
||||
console.warn(
|
||||
"[email] EMAIL_PASSWORD not set — skipping email send to:",
|
||||
to
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: "smtp.migadu.com",
|
||||
port: 465,
|
||||
secure: true,
|
||||
auth: {
|
||||
user: "hunter@repi.fun",
|
||||
pass: password,
|
||||
},
|
||||
});
|
||||
|
||||
await transporter.sendMail({
|
||||
from: "CodeBoard <hunter@repi.fun>",
|
||||
to,
|
||||
subject,
|
||||
html,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user