This commit is contained in:
2026-02-25 07:27:30 +00:00
parent acd7713c86
commit cf121e2fee
11 changed files with 413 additions and 21 deletions
+33
View File
@@ -0,0 +1,33 @@
import { join } from 'node:path';
import { existsSync, readFileSync, appendFileSync, mkdirSync } from 'node:fs';
import { createRouter } from '../../create-router';
import { DATA_PATH } from '../../data-path';
export const waitlistRouter = createRouter();
const WAITLIST_FILE = join(DATA_PATH, 'waitlist.txt');
waitlistRouter.post('/', async (ctx) => {
const body = await ctx.req.json<{ email?: string }>();
const email = body.email?.trim().toLowerCase();
if (!email || !email.includes('@')) {
return ctx.json({ error: 'Invalid email' }, 400);
}
const dir = DATA_PATH;
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
if (existsSync(WAITLIST_FILE)) {
const existing = readFileSync(WAITLIST_FILE, 'utf-8');
const emails = existing.split('\n').map((l) => l.trim().toLowerCase());
if (emails.includes(email)) {
return ctx.json({ ok: true });
}
}
appendFileSync(WAITLIST_FILE, email + '\n', 'utf-8');
return ctx.json({ ok: true });
});