Upgrade linter and formatter to Ultracite (#1224)
This commit is contained in:
parent
b1d254283b
commit
0e320b391d
177 changed files with 6951 additions and 8342 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { NextResponse, type NextRequest } from 'next/server';
|
||||
import { getToken } from 'next-auth/jwt';
|
||||
import { guestRegex, isDevelopmentEnvironment } from './lib/constants';
|
||||
import { type NextRequest, NextResponse } from "next/server";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { guestRegex, isDevelopmentEnvironment } from "./lib/constants";
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
|
@ -9,11 +9,11 @@ export async function middleware(request: NextRequest) {
|
|||
* Playwright starts the dev server and requires a 200 status to
|
||||
* begin the tests, so this ensures that the tests can start
|
||||
*/
|
||||
if (pathname.startsWith('/ping')) {
|
||||
return new Response('pong', { status: 200 });
|
||||
if (pathname.startsWith("/ping")) {
|
||||
return new Response("pong", { status: 200 });
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/api/auth')) {
|
||||
if (pathname.startsWith("/api/auth")) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
|
|
@ -27,14 +27,14 @@ export async function middleware(request: NextRequest) {
|
|||
const redirectUrl = encodeURIComponent(request.url);
|
||||
|
||||
return NextResponse.redirect(
|
||||
new URL(`/api/auth/guest?redirectUrl=${redirectUrl}`, request.url),
|
||||
new URL(`/api/auth/guest?redirectUrl=${redirectUrl}`, request.url)
|
||||
);
|
||||
}
|
||||
|
||||
const isGuest = guestRegex.test(token?.email ?? '');
|
||||
const isGuest = guestRegex.test(token?.email ?? "");
|
||||
|
||||
if (token && !isGuest && ['/login', '/register'].includes(pathname)) {
|
||||
return NextResponse.redirect(new URL('/', request.url));
|
||||
if (token && !isGuest && ["/login", "/register"].includes(pathname)) {
|
||||
return NextResponse.redirect(new URL("/", request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
|
|
@ -42,11 +42,11 @@ export async function middleware(request: NextRequest) {
|
|||
|
||||
export const config = {
|
||||
matcher: [
|
||||
'/',
|
||||
'/chat/:id',
|
||||
'/api/:path*',
|
||||
'/login',
|
||||
'/register',
|
||||
"/",
|
||||
"/chat/:id",
|
||||
"/api/:path*",
|
||||
"/login",
|
||||
"/register",
|
||||
|
||||
/*
|
||||
* Match all request paths except for the ones starting with:
|
||||
|
|
@ -54,6 +54,6 @@ export const config = {
|
|||
* - _next/image (image optimization files)
|
||||
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
|
||||
*/
|
||||
'/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
|
||||
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
|
||||
],
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue