-
Notifications
You must be signed in to change notification settings - Fork 188
feat(admin): introduce admin dashboard and related configurations #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92fdd80
feat(admin): introduce admin dashboard and related configurations
smakosh 66998b2
chore(autofix): apply diff
steebchen 0384cc4
Merge remote-tracking branch 'origin/main' into feat/admin-dashboard
steebchen c27710a
chore: add admin to build matrix in images.yml
steebchen bed48ca
chore: update environment variables in docker-compose files
steebchen cb13c6c
chore: add admin builder stage to Dockerfile
steebchen 32cfcec
chore: update admin endpoint in Docker test scripts
steebchen 4a8a616
fix: add Docker cleanup in test-split job
steebchen 726ad6b
fix: add aggressive disk cleanup for test-split
steebchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |
| **/.pnpm-store | ||
| **/.idea | ||
| **/openapi.json | ||
| **/.vinxi | ||
| **/.next | ||
| **/.next-dev | ||
| **/.vercel | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/versions | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # next.js | ||
| /.next-dev/ | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # env files (can opt-in for committing if needed) | ||
| .env* | ||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "package.json": "pnpm sort-package-json", | ||
| "**/*.{js,jsx,ts,tsx}": ["pnpm eslint --fix", "pnpm prettier --write"], | ||
| "**/*.{md,mdx,json,yml,yaml}": ["pnpm prettier --write"] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .content-collections | ||
| .next | ||
| v1.d.ts |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). | ||
|
|
||
| ## Getting Started | ||
|
|
||
| First, run the development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| # or | ||
| pnpm dev | ||
| # or | ||
| bun dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
|
||
| You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
|
||
| This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. | ||
|
|
||
| ## Learn More | ||
|
|
||
| To learn more about Next.js, take a look at the following resources: | ||
|
|
||
| - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
| - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
|
||
| You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! | ||
|
|
||
| ## Deploy on Vercel | ||
|
|
||
| The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
|
||
| Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "$schema": "https://ui.shadcn.com/schema.json", | ||
| "style": "new-york", | ||
| "rsc": true, | ||
| "tsx": true, | ||
| "tailwind": { | ||
| "config": "", | ||
| "css": "src/app/globals.css", | ||
| "baseColor": "zinc", | ||
| "cssVariables": true, | ||
| "prefix": "" | ||
| }, | ||
| "iconLibrary": "lucide", | ||
| "aliases": { | ||
| "components": "@/components", | ||
| "utils": "@/lib/utils", | ||
| "ui": "@/components/ui", | ||
| "lib": "@/lib", | ||
| "hooks": "@/hooks" | ||
| }, | ||
| "registries": {} | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import lint from "../../eslint.config.mjs"; | ||
| import react from "@abinnovision/eslint-config-react"; | ||
|
|
||
| /** @type {import("eslint").Linter.Config[]} */ | ||
| export default [ | ||
| ...lint, | ||
| ...react, | ||
| { | ||
| rules: { | ||
| "no-console": "off", | ||
| "react/no-unescaped-entities": "off", | ||
| }, | ||
| }, | ||
| { | ||
| ignores: ["**/v1.d.ts"], | ||
| }, | ||
| ]; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { NextResponse } from "next/server"; | ||
|
|
||
| import type { NextRequest } from "next/server"; | ||
|
|
||
| interface MeResponse { | ||
| user: { | ||
| id: string; | ||
| email: string; | ||
| isAdmin?: boolean; | ||
| }; | ||
| } | ||
|
|
||
| export async function middleware(req: NextRequest) { | ||
| const { pathname } = req.nextUrl; | ||
|
|
||
| // Allow auth and static routes without admin check | ||
| if ( | ||
| pathname.startsWith("/login") || | ||
| pathname.startsWith("/signup") || | ||
| pathname.startsWith("/_next") || | ||
| pathname.startsWith("/favicon") || | ||
| pathname.startsWith("/api") | ||
| ) { | ||
| return NextResponse.next(); | ||
| } | ||
|
|
||
| const apiUrl = | ||
| process.env.API_BACKEND_URL || | ||
| process.env.API_URL || | ||
| "http://localhost:4002"; | ||
|
|
||
| const key = "better-auth.session_token"; | ||
| const cookies = req.cookies; | ||
| const secureSession = cookies.get(`__Secure-${key}`)?.value; | ||
| const session = cookies.get(key)?.value; | ||
|
|
||
| const cookieHeader = secureSession | ||
| ? `__Secure-${key}=${secureSession}` | ||
| : session | ||
| ? `${key}=${session}` | ||
| : ""; | ||
|
|
||
| if (!cookieHeader) { | ||
| const loginUrl = new URL("/login", req.url); | ||
| loginUrl.searchParams.set("returnUrl", pathname || "/"); | ||
| return NextResponse.redirect(loginUrl); | ||
| } | ||
|
|
||
| try { | ||
| const res = await fetch(`${apiUrl}/user/me`, { | ||
| method: "GET", | ||
| headers: { | ||
| Cookie: cookieHeader, | ||
| }, | ||
| }); | ||
|
|
||
| if (!res.ok) { | ||
| const loginUrl = new URL("/login", req.url); | ||
| loginUrl.searchParams.set("returnUrl", pathname || "/"); | ||
| return NextResponse.redirect(loginUrl); | ||
| } | ||
|
|
||
| const data = (await res.json()) as MeResponse; | ||
|
|
||
| if (!data.user?.isAdmin) { | ||
| return new NextResponse("Forbidden: admin access required", { | ||
| status: 403, | ||
| }); | ||
| } | ||
| } catch { | ||
| return new NextResponse("Forbidden: admin access required", { | ||
| status: 403, | ||
| }); | ||
| } | ||
|
|
||
| return NextResponse.next(); | ||
| } | ||
|
|
||
| export const config = { | ||
| matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"], | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.