From c7e409b1372bb7b7c76550b478bc3cb4f62e70b7 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Yadav Date: Mon, 22 Jun 2026 13:40:21 +0530 Subject: [PATCH 1/4] feat(tools): add batch email sending utility --- tools/db-queries/emails.txt | 1 + tools/send-student-emails.js | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tools/db-queries/emails.txt create mode 100644 tools/send-student-emails.js diff --git a/tools/db-queries/emails.txt b/tools/db-queries/emails.txt new file mode 100644 index 000000000..bb5648c23 --- /dev/null +++ b/tools/db-queries/emails.txt @@ -0,0 +1 @@ +senkuishigami@gmail.com \ No newline at end of file diff --git a/tools/send-student-emails.js b/tools/send-student-emails.js new file mode 100644 index 000000000..479a4ccfb --- /dev/null +++ b/tools/send-student-emails.js @@ -0,0 +1,67 @@ +const fs = require('fs'); +const path = require('path'); +const { Resend } = require('resend'); +require('dotenv').config(); + +const resend = new Resend( + process.env.RESEND_API_KEY_2 || + process.env.RESEND_API_KEY +); + +const BATCH_SIZE = 100; + +async function sendEmail(email) { + return resend.emails.send({ + from: process.env.EMAIL_FROM || 'onboarding@resend.dev', + to: email, + subject: 'Try urBackend', + html: ` +

Hi there 👋

+ +

I'm building urBackend, an open-source backend platform that helps developers build APIs and backend services faster.

+ +

I'd love for you to try it out and share feedback.

+ +

+ + Try urBackend + +

+ +

Thanks!

+ ` + }); +} + +async function main() { + const emails = fs + .readFileSync( + path.join(__dirname, 'emails.txt'), + 'utf8' + ) + .split(/\r?\n/) + .map(e => e.trim()) + .filter(Boolean); + + const batchSize = parseInt(process.argv[2]) || 100; + const batch = emails.slice(0, batchSize); + console.log(`Sending ${batch.length} emails...`); + + for (const email of batch) { + try { + await sendEmail(email); + console.log(`✓ ${email}`); + + await new Promise(resolve => + setTimeout(resolve, 1000) + ); + + } catch (err) { + console.error(`✗ ${email}`, err.message); + } + } + + console.log('Finished'); +} + +main(); \ No newline at end of file From 528a5ecc38d79f4d76ea8d7fbd7b411ee381a1d1 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Yadav Date: Mon, 22 Jun 2026 13:59:04 +0530 Subject: [PATCH 2/4] fix issued by coderabbit --- tools/{db-queries => }/emails.txt | 0 tools/send-student-emails.js | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) rename tools/{db-queries => }/emails.txt (100%) diff --git a/tools/db-queries/emails.txt b/tools/emails.txt similarity index 100% rename from tools/db-queries/emails.txt rename to tools/emails.txt diff --git a/tools/send-student-emails.js b/tools/send-student-emails.js index 479a4ccfb..fa6be3529 100644 --- a/tools/send-student-emails.js +++ b/tools/send-student-emails.js @@ -12,7 +12,7 @@ const BATCH_SIZE = 100; async function sendEmail(email) { return resend.emails.send({ - from: process.env.EMAIL_FROM || 'onboarding@resend.dev', + from: process.env.EMAIL_FROM || 'urBackend ', to: email, subject: 'Try urBackend', html: ` @@ -43,21 +43,27 @@ async function main() { .map(e => e.trim()) .filter(Boolean); - const batchSize = parseInt(process.argv[2]) || 100; - const batch = emails.slice(0, batchSize); + const parsed = Number(process.argv[2]); + const batchSize = Number.isInteger(parsed) && parsed > 0 ? parsed : BATCH_SIZE; + const batch = emails.slice(0, Math.min(batchSize, emails.length)); console.log(`Sending ${batch.length} emails...`); + const redactEmail = (value) => { + const [local, domain] = String(value).split('@'); + if (!domain) return '***'; + return `${local?.slice(0, 2) || '**'}***@${domain}`; + }; + for (const email of batch) { try { await sendEmail(email); - console.log(`✓ ${email}`); - + console.error(`✗ ${redactEmail(email)}`, err.message); await new Promise(resolve => setTimeout(resolve, 1000) ); } catch (err) { - console.error(`✗ ${email}`, err.message); + console.error(`✗ ${redactEmail(email)}`, err.message); } } From 7e73475921c5642a38d4d82ab24c1c071351f0e9 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Yadav Date: Mon, 22 Jun 2026 14:00:45 +0530 Subject: [PATCH 3/4] removed email --- tools/emails.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/emails.txt b/tools/emails.txt index bb5648c23..e69de29bb 100644 --- a/tools/emails.txt +++ b/tools/emails.txt @@ -1 +0,0 @@ -senkuishigami@gmail.com \ No newline at end of file From a94e10a9fa3f7a5b78d4c41a23e61c8e9cb2dc9d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Yadav Date: Mon, 22 Jun 2026 14:11:14 +0530 Subject: [PATCH 4/4] file name changed --- tools/{send-student-emails.js => promotional-emails.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{send-student-emails.js => promotional-emails.js} (100%) diff --git a/tools/send-student-emails.js b/tools/promotional-emails.js similarity index 100% rename from tools/send-student-emails.js rename to tools/promotional-emails.js