chore: add script for listing newsletter contacts

This commit is contained in:
javayhu 2025-05-16 09:59:18 +08:00
parent ecb57cf7ab
commit c41817c704
3 changed files with 28 additions and 2 deletions

View File

@ -1,8 +1,8 @@
# MkSaaS
Make AI SaaS in days, simply and effortlessly.
Make AI SaaS in a weekend.
MkSaaS is a complete Next.js boilerplate for building AI SaaS websites. Make money from day one with our battle-tested stack and built-in monetization features.
The complete Next.js boilerplate for building profitable SaaS, with auth, payments, i18n, newsletter, dashboard, blog, docs, blocks, themes, SEO and more.
## Author

View File

@ -13,6 +13,7 @@
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio",
"list-contacts": "tsx scripts/list-contacts.ts",
"docs": "content-collections build",
"email": "email dev --dir src/mail/templates --port 3333"
},

25
scripts/list-contacts.ts Normal file
View File

@ -0,0 +1,25 @@
import dotenv from 'dotenv';
import { Resend } from 'resend';
dotenv.config();
const resend = new Resend(process.env.RESEND_API_KEY);
export default async function listContacts() {
const contacts = await resend.contacts.list({
audienceId: process.env.RESEND_AUDIENCE_ID!,
});
// print all emails
const emails: string[] = [];
if (Array.isArray(contacts.data?.data)) {
for (const contact of contacts.data.data) {
emails.push(contact.email);
}
} else {
console.error('contacts is not iterable');
}
console.log(emails.join(', '));
}
listContacts();