fix: BUG-012 remove email requirement from free signup + fix 429 handling
This commit is contained in:
parent
73bb041513
commit
3c0bac889a
4 changed files with 35 additions and 37 deletions
|
|
@ -20,20 +20,19 @@ const signupLimiter = rateLimit({
|
|||
|
||||
// Self-service free API key signup
|
||||
router.post("/free", signupLimiter, (req: Request, res: Response) => {
|
||||
const { email } = req.body;
|
||||
const { email } = req.body || {};
|
||||
|
||||
if (!email || typeof email !== "string") {
|
||||
res.status(400).json({ error: "Email is required" });
|
||||
return;
|
||||
// Email is optional — validate only if provided
|
||||
let cleanEmail: string | undefined;
|
||||
if (email && typeof email === "string") {
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "Invalid email address" });
|
||||
return;
|
||||
}
|
||||
cleanEmail = email.trim().toLowerCase();
|
||||
}
|
||||
|
||||
// Basic email validation
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "Invalid email address" });
|
||||
return;
|
||||
}
|
||||
|
||||
const keyInfo = createFreeKey(email.trim().toLowerCase());
|
||||
const keyInfo = createFreeKey(cleanEmail);
|
||||
|
||||
res.json({
|
||||
message: "Welcome to DocFast! 🚀",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue