feat: monitors worker, auth register, scan polish

Add background DNS/SSL monitor checks, registration API, smoother SSE
with stage labels, improved CDN/WAF detection, light-theme UI polish,
and README roadmap updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Андрей Бобырев
2026-05-24 23:33:15 +03:00
parent 1196bc3d11
commit 010e053ca1
21 changed files with 1166 additions and 75 deletions

View File

@@ -0,0 +1,42 @@
import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";
import bcrypt from "bcryptjs";
import { prisma } from "@/lib/prisma";
const bodySchema = z.object({
email: z.string().email().max(255),
password: z.string().min(8).max(128),
name: z.string().max(120).optional(),
});
export async function POST(req: NextRequest) {
let body: z.infer<typeof bodySchema>;
try {
body = bodySchema.parse(await req.json());
} catch {
return NextResponse.json({ error: "Invalid request" }, { status: 400 });
}
const email = body.email.toLowerCase();
const existing = await prisma.user.findUnique({ where: { email } });
if (existing) {
return NextResponse.json({ error: "Email already registered" }, { status: 409 });
}
const seedEmail = process.env.SEED_ADMIN_EMAIL?.toLowerCase();
const role =
seedEmail && email === seedEmail ? ("ADMIN" as const) : ("USER" as const);
const passwordHash = await bcrypt.hash(body.password, 12);
const user = await prisma.user.create({
data: {
email,
name: body.name,
passwordHash,
role,
},
select: { id: true, email: true, role: true },
});
return NextResponse.json({ user }, { status: 201 });
}

View File

@@ -31,6 +31,7 @@ export async function GET(
id: scan.id,
status: scan.status,
progress: scan.progress,
stage: scan.stage,
domain: scan.domain,
result: scan.status === "COMPLETED" ? scan.result : undefined,
error: scan.error,
@@ -48,7 +49,7 @@ export async function GET(
return;
}
setTimeout(poll, 1000);
setTimeout(poll, 450);
};
await poll();

View File

@@ -62,8 +62,11 @@ export async function POST(req: NextRequest) {
async function runScanAsync(scanId: string, domain: string, cacheKey: string) {
try {
const result = await runDomainScan(domain, async (progress) => {
await prisma.scan.update({ where: { id: scanId }, data: { progress } });
const result = await runDomainScan(domain, async (progress, stage) => {
await prisma.scan.update({
where: { id: scanId },
data: { progress, stage },
});
});
await prisma.scan.update({
where: { id: scanId },