mirror of
https://github.com/andrey271192/Domain_web.git
synced 2026-09-20 14:41:58 +00:00
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:
42
src/app/api/auth/register/route.ts
Normal file
42
src/app/api/auth/register/route.ts
Normal 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 });
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user