-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
186 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import { QueryClient } from "@tanstack/react-query"; | ||
import { cache } from "react"; | ||
|
||
// global query client for server components only, to not make any duplicate requests | ||
/** | ||
* Creates and caches a global QueryClient instance for server components. | ||
* | ||
* This function uses React's `cache` to ensure that only one QueryClient | ||
* instance is created and reused across all server components. This helps | ||
* prevent duplicate requests and maintains consistent state. | ||
* | ||
* @returns A cached instance of QueryClient | ||
*/ | ||
const getQueryClient = cache(() => new QueryClient()); | ||
export default getQueryClient; | ||
|
||
export default getQueryClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { NextResponse, type NextRequest } from "next/server"; | ||
import { serverEnv } from "./utils/env/server"; | ||
|
||
/** | ||
* Middleware function to set the server URL in the request headers so it can be read while in server components. | ||
*/ | ||
export default async function middleware(request: NextRequest) { | ||
const headers = new Headers(request.headers); | ||
headers.set(serverEnv.SERVER_URL_KEY, request.url); | ||
return NextResponse.next({ headers }); | ||
} | ||
|
||
/** | ||
* Configuration for the middleware, specifying which routes it should run on. | ||
*/ | ||
export const config = { | ||
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { Type as t, type Static } from "@sinclair/typebox/type"; | ||
|
||
/** | ||
* TypeBox schema Can be used for elysia body params or query schema and in frontend form validation. | ||
*/ | ||
export const authUser = t.Object({ | ||
username: t.String({ minLength: 1, maxLength: 128 }), | ||
password: t.String({ minLength: 1, maxLength: 128 }), | ||
test: t.Optional(t.String({ minLength: 1, maxLength: 128 })), | ||
}); | ||
|
||
/** | ||
* TypeScript type derived from the authUser schema. | ||
*/ | ||
export type AuthUser = Static<typeof authUser>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.