M3 frontend infrastructure for the newzy news application: - Vite + React 18 + TypeScript project (Node >=18) in frontend/ - React Router v6: BrowserRouter in App.tsx, routes for /, /articles, /articles/:id and /categories, Link/NavLink-based navigation - lucide-react icons (Home, FileText, Settings, Search, ...) in the responsive Header (desktop + mobile menu) and article components - Reusable components: ArticleCard, AuthorAvatar, CategoryBadge (CVA), Layout shell with backend API status indicator in the footer - Typed API client (fetch wrapper, ApiError, endpoint helpers) with types matching the backend models; sample-data fallback until the backend article endpoints exist - Tailwind CSS global/component styles, cn() helper (clsx + tailwind-merge) - Unit tests: Vitest + React Testing Library (23 tests, 100% statement coverage on components) - E2E tests: Playwright (9 tests) covering page shell, feed rendering, client-side navigation, article route and API interactions - ESLint (react + react-hooks + typescript) configured and passing - Multi-stage Dockerfile (Vite build -> Nginx) with SPA fallback and an /api/ proxy to the backend service; docker-compose frontend service on port 3000 in both frontend/ and the root docker-compose.yml - README with setup, API documentation, testing and Docker instructions
46 lines
1.4 KiB
Nginx Configuration File
46 lines
1.4 KiB
Nginx Configuration File
# newzy frontend — Nginx configuration (Docker).
|
|
#
|
|
# Serves the Vite production build as a single-page app and proxies API
|
|
# calls to the backend service so the browser can use relative /api URLs
|
|
# (no CORS needed from within the compose network).
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Reasonable defaults for static content.
|
|
sendfile on;
|
|
gzip on;
|
|
gzip_types text/css application/javascript application/json image/svg+xml;
|
|
|
|
# Hashed build assets can be cached aggressively.
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Docker's built-in DNS. The upstream is resolved at request time (via a
|
|
# variable) instead of at startup, so nginx still boots when the backend
|
|
# service is not yet available (requests then fail with 502 instead).
|
|
resolver 127.0.0.11 valid=30s ipv6=off;
|
|
|
|
# Proxy API calls to the FastAPI backend service.
|
|
location /api/ {
|
|
set $api_upstream "http://backend:8000";
|
|
proxy_pass $api_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
# SPA fallback: unknown paths are handled by React Router.
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|