refactor: switch SDK methods to asynchronous

Migrate SDK interactions to asynchronous calls, relax admin setup email constraints, and add event retrieval functionality.
This commit is contained in:
Team Dark Devil committed 2026-11-17 20:05:00 +06:00
1 parent 81c5e4e2fd
commit bb938c33c0
36 files changed
+1679 -754

No files matched your search

+16 -2
View File
@@ -43,13 +43,23 @@ export async function middleware(request: NextRequest) {
!isLoginPage &&
!isSetupPage;
const isAdminApi = isProtectedApi(pathname, request.method);
const hasBearerAuth = Boolean(
request.headers.get("authorization")?.toLowerCase().startsWith("bearer "),
);
const isStateChangingApi =
pathname.startsWith("/api/") &&
!SAFE_METHODS.has(request.method) &&
pathname !== "/api/events";
!(pathname === "/api/events" && hasBearerAuth);
if (isSetupPage) return NextResponse.next();
if (!isConsolePage && !isAdminApi && !isLoginPage) return NextResponse.next();
if (
!isConsolePage &&
!isAdminApi &&
!isLoginPage &&
!(pathname === "/api/events" && request.method === "POST")
) {
return NextResponse.next();
}
if (isStateChangingApi && !isSameOriginRequest(request)) {
return NextResponse.json(
@@ -58,6 +68,10 @@ export async function middleware(request: NextRequest) {
);
}
if (pathname === "/api/events" && request.method === "POST") {
return NextResponse.next();
}
const sessionSecret =
process.env.DATASTACK_ADMIN_SESSION_SECRET ||
"datastack-admin-session-default-secret-32-chars";