Files
lets-event/middleware.ts
T
Edgar Muniz Berlinck 79bff52f25 Replace ESLint with Biome and fix CI pipeline
Changes:
- Remove ESLint and eslint-config-next
- Add Biome 2.4.4 for linting and formatting
- Create biome.json with project configuration
- Update lint script to use Biome with npx
- Add format script for Biome

CI Pipeline Updates:
- Use biomejs/setup-biome@v2 action for lint job
- Move env variables to workflow level
- Use postgres:16-alpine for consistency
- Fix Playwright browser installation (run after npm ci)
- Add workflow_dispatch for manual triggering
- Proper job dependencies: build → lint + e2e

Code Fixes (Biome auto-fix):
- Add 'node:' protocol to Node.js imports
- Convert type-only imports to 'import type'
- Apply recommended Biome formatting

All 29 files checked and fixed by Biome 
2026-02-27 01:26:09 +01:00

27 lines
759 B
TypeScript

import NextAuth from "next-auth";
import { authConfig } from "./auth.config";
export const { auth } = NextAuth(authConfig);
export default auth((req) => {
const isLoggedIn = !!req.auth;
const isAuthRoute =
req.nextUrl.pathname.startsWith("/login") ||
req.nextUrl.pathname.startsWith("/register");
const isDashboardRoute = req.nextUrl.pathname.startsWith("/dashboard");
if (isDashboardRoute && !isLoggedIn) {
const loginUrl = new URL("/login", req.url);
return Response.redirect(loginUrl);
}
if (isAuthRoute && isLoggedIn) {
const dashboardUrl = new URL("/dashboard", req.url);
return Response.redirect(dashboardUrl);
}
});
export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
};