From 898e275809b4d82f95297961c473cce27fe4b966 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Sun, 3 Aug 2025 11:38:09 +0200 Subject: [PATCH] adds prod container and fixes build issues --- backend/playlist/views/api/profile.py | 8 ++++++++ backend/playlist/views/api/user.py | 2 ++ docker-compose.yml | 10 ++++++++++ frontend/src/app/users/page.tsx | 2 +- frontend/src/components/Quota.tsx | 2 +- frontend/src/data/fetcher.ts | 6 +++--- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/backend/playlist/views/api/profile.py b/backend/playlist/views/api/profile.py index d027d9b..2cfb3eb 100644 --- a/backend/playlist/views/api/profile.py +++ b/backend/playlist/views/api/profile.py @@ -4,7 +4,15 @@ from rest_framework.views import APIView from rest_framework.response import Response from playlist.serializers import ProfileSerializer, ProfileUpdateSerializer, BackgroundSerializer from playlist.models import Profile, Background +from drf_spectacular.utils import extend_schema +@extend_schema( + summary="Get the current user's profile", + description="Retrieve the profile information of the currently authenticated user.", + responses={ + 200: ProfileSerializer, + }, +) class ProfileMeView(APIView): def get(self, request): profile = request.user.profile diff --git a/backend/playlist/views/api/user.py b/backend/playlist/views/api/user.py index f585c78..64f8803 100644 --- a/backend/playlist/views/api/user.py +++ b/backend/playlist/views/api/user.py @@ -2,7 +2,9 @@ from rest_framework.views import APIView from rest_framework.response import Response from django.contrib.auth.models import User from playlist.serializers import UserSerializer +from drf_spectacular.utils import extend_schema +@extend_schema(responses={200: UserSerializer}) class UserListView(APIView): def get(self, request): users = User.objects.all() diff --git a/docker-compose.yml b/docker-compose.yml index 87d01ff..b2dc692 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,16 @@ services: - "3001:3000" networks: - app_network + prod: + image: node:20 + working_dir: /app/frontend + volumes: + - ./frontend:/app/frontend + command: sh -c "npm install && npx next build && npx next start" + ports: + - "3003:3000" + networks: + - app_network networks: app_network: diff --git a/frontend/src/app/users/page.tsx b/frontend/src/app/users/page.tsx index c66aa9d..6c680ab 100644 --- a/frontend/src/app/users/page.tsx +++ b/frontend/src/app/users/page.tsx @@ -9,7 +9,7 @@ export default function Page() { useEffect(() => { async function getUsers() { const { data: users } = await api.users.list({}); - setUserData(users); + setUserData(Array.isArray(users) ? users : [users]); } getUsers(); }, []); diff --git a/frontend/src/components/Quota.tsx b/frontend/src/components/Quota.tsx index 71def44..924609e 100644 --- a/frontend/src/components/Quota.tsx +++ b/frontend/src/components/Quota.tsx @@ -18,7 +18,7 @@ export default function Quota({ async function getProfile() { if (!auth.isLoading && !auth.error && auth.isAuthenticated) { const { data: profile } = await api?.profiles?.me({}); - setQuota(profile?.quota); + setQuota((profile as Profile)?.quota); } } useEffect(() => { diff --git a/frontend/src/data/fetcher.ts b/frontend/src/data/fetcher.ts index 2eaffe0..bef1cf2 100644 --- a/frontend/src/data/fetcher.ts +++ b/frontend/src/data/fetcher.ts @@ -4,7 +4,8 @@ import { getUser } from "./fetch"; import { paths, components } from "muzak/data/types"; const fetcher = Fetcher.for(); -const BASE_URL = process.env.BACKEND_HOST!; +const BASE_URL = process.env.NEXT_PUBLIC_BACKEND_HOST!; +console.log("beest url", BASE_URL); // Configure the fetcher fetcher.configure({ @@ -19,7 +20,7 @@ fetcher.configure({ async (url, init, next) => { const user = getUser(); if (user?.access_token) { - init.headers = { + (init.headers as any) = { ...init.headers, Authorization: `Bearer ${user.access_token}`, "Content-Type": "application/json", @@ -76,7 +77,6 @@ export const api = { export type User = components["schemas"]["User"]; export type Track = components["schemas"]["Track"]; export type Album = components["schemas"]["Album"]; -export type Vote = components["schemas"]["Vote"]; export type Profile = components["schemas"]["Profile"]; export default api;