fastapi-fullstack 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_fullstack-0.1.7.dist-info/METADATA +739 -0
- fastapi_fullstack-0.1.7.dist-info/RECORD +241 -0
- fastapi_fullstack-0.1.7.dist-info/WHEEL +4 -0
- fastapi_fullstack-0.1.7.dist-info/entry_points.txt +2 -0
- fastapi_fullstack-0.1.7.dist-info/licenses/LICENSE +21 -0
- fastapi_gen/__init__.py +3 -0
- fastapi_gen/cli.py +442 -0
- fastapi_gen/config.py +356 -0
- fastapi_gen/generator.py +207 -0
- fastapi_gen/prompts.py +874 -0
- fastapi_gen/template/VARIABLES.md +276 -0
- fastapi_gen/template/cookiecutter.json +93 -0
- fastapi_gen/template/hooks/post_gen_project.py +355 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.env.prod.example +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +150 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.gitignore +109 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/AGENTS.md +55 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/CLAUDE.md +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/Makefile +315 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/README.md +768 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.dockerignore +60 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.env.example +155 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.pre-commit-config.yaml +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/Dockerfile +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/script.py.mako +30 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic.ini +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/__init__.py +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/admin.py +447 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/__init__.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/assistant.py +226 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/langchain_assistant.py +226 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/prompts.py +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/__init__.py +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/datetime_tool.py +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/deps.py +541 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/exception_handlers.py +98 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/router.py +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/__init__.py +87 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/agent.py +902 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/auth.py +395 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/conversations.py +498 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/health.py +227 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/items.py +275 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/oauth.py +205 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/sessions.py +168 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/users.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/webhooks.py +477 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/ws.py +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/versioning.py +221 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/__init__.py +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/redis.py +88 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/__init__.py +117 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/cleanup.py +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/example.py +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/seed.py +266 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/cache.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/config.py +267 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/csrf.py +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/exceptions.py +122 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/logfire_setup.py +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/middleware.py +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/oauth.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/rate_limit.py +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/sanitize.py +271 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/security.py +102 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/__init__.py +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/base.py +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/__init__.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/conversation.py +319 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/item.py +96 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/session.py +126 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/user.py +218 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/webhook.py +244 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/session.py +130 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/main.py +334 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/base.py +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/__init__.py +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/base.py +154 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/conversation.py +838 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/item.py +222 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/session.py +318 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py +322 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/webhook.py +358 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/__init__.py +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/base.py +57 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/conversation.py +192 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/item.py +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/session.py +42 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/token.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/user.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/webhook.py +89 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/__init__.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/conversation.py +850 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/item.py +246 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/session.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py +432 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/webhook.py +561 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/celery_app.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/taskiq_app.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/__init__.py +25 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/examples.py +106 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/schedules.py +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/taskiq_examples.py +92 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/commands.py +438 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/pyproject.toml +180 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/scripts/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_auth.py +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_exceptions.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_health.py +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_items.py +310 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_users.py +253 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/conftest.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_admin.py +890 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_agents.py +261 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_clients.py +183 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_commands.py +173 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_core.py +143 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pipelines.py +118 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_repositories.py +181 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_security.py +124 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_services.py +363 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_worker.py +85 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.frontend.yml +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml +435 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml +241 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/adding_features.md +132 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/architecture.md +63 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/patterns.md +161 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/testing.md +120 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.dockerignore +40 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.env.example +12 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.gitignore +45 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierignore +19 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierrc +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/Dockerfile +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/README.md +648 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.setup.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.spec.ts +134 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/chat.spec.ts +207 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/home.spec.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/instrumentation.ts +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/en.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/pl.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/next.config.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/package.json +69 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/playwright.config.ts +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/postcss.config.mjs +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/layout.tsx +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/login/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/register/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/chat/page.tsx +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/dashboard/page.tsx +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/layout.tsx +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/profile/page.tsx +152 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/auth/callback/page.tsx +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/layout.tsx +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/page.tsx +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/login/route.ts +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/logout/route.ts +24 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/me/route.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/oauth-callback/route.ts +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/refresh/route.ts +54 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/register/route.ts +26 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/messages/route.ts +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/route.ts +108 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/route.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/health/route.ts +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/globals.css +323 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/layout.tsx +22 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/providers.tsx +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/login-form.tsx +120 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/register-form.tsx +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-container.tsx +234 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-input.tsx +72 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/conversation-sidebar.tsx +328 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/copy-button.tsx +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/index.ts +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/local-conversation-sidebar.tsx +295 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/markdown-content.tsx +167 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-item.tsx +79 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-list.tsx +18 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/tool-call-card.tsx +79 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/google-icon.tsx +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/index.ts +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/language-switcher.tsx +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/header.tsx +65 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/sidebar.tsx +82 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/index.ts +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-provider.tsx +53 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-toggle.tsx +105 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/badge.tsx +35 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.test.tsx +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.tsx +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/card.tsx +82 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/index.ts +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/input.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/label.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/sheet.tsx +109 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/index.ts +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-auth.ts +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-chat.ts +203 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-conversations.ts +181 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-local-chat.ts +165 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-websocket.ts +105 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/i18n.ts +37 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/api-client.ts +90 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/constants.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/server-api.ts +78 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.test.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/middleware.ts +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.test.ts +72 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.ts +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/chat-sidebar-store.ts +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/chat-store.ts +65 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/conversation-store.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/index.ts +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/local-chat-store.ts +255 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/sidebar-store.ts +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/theme-store.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/api.ts +27 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/auth.ts +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/chat.ts +83 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/conversation.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/index.ts +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/tsconfig.json +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.config.ts +36 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.setup.ts +56 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
/* Light theme - neutral grays with better contrast */
|
|
5
|
+
--color-background: oklch(97% 0 0);
|
|
6
|
+
--color-foreground: oklch(15% 0 0);
|
|
7
|
+
--color-card: oklch(100% 0 0);
|
|
8
|
+
--color-card-foreground: oklch(15% 0 0);
|
|
9
|
+
--color-popover: oklch(100% 0 0);
|
|
10
|
+
--color-popover-foreground: oklch(15% 0 0);
|
|
11
|
+
--color-primary: oklch(25% 0 0);
|
|
12
|
+
--color-primary-foreground: oklch(98% 0 0);
|
|
13
|
+
--color-secondary: oklch(93% 0 0);
|
|
14
|
+
--color-secondary-foreground: oklch(20% 0 0);
|
|
15
|
+
--color-muted: oklch(93% 0 0);
|
|
16
|
+
--color-muted-foreground: oklch(45% 0 0);
|
|
17
|
+
--color-accent: oklch(93% 0 0);
|
|
18
|
+
--color-accent-foreground: oklch(20% 0 0);
|
|
19
|
+
--color-destructive: oklch(57.7% 0.245 27.325);
|
|
20
|
+
--color-destructive-foreground: oklch(98.5% 0 0);
|
|
21
|
+
--color-border: oklch(88% 0 0);
|
|
22
|
+
--color-input: oklch(88% 0 0);
|
|
23
|
+
--color-ring: oklch(25% 0 0);
|
|
24
|
+
--radius: 0.5rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Dark theme - triggered by system preference or .dark class */
|
|
28
|
+
@media (prefers-color-scheme: dark) {
|
|
29
|
+
:root:not(.light) {
|
|
30
|
+
/* Dark theme - neutral with better contrast between sections */
|
|
31
|
+
--color-background: oklch(12% 0 0);
|
|
32
|
+
--color-foreground: oklch(95% 0 0);
|
|
33
|
+
--color-card: oklch(18% 0 0);
|
|
34
|
+
--color-card-foreground: oklch(95% 0 0);
|
|
35
|
+
--color-popover: oklch(18% 0 0);
|
|
36
|
+
--color-popover-foreground: oklch(95% 0 0);
|
|
37
|
+
--color-primary: oklch(95% 0 0);
|
|
38
|
+
--color-primary-foreground: oklch(12% 0 0);
|
|
39
|
+
--color-secondary: oklch(22% 0 0);
|
|
40
|
+
--color-secondary-foreground: oklch(95% 0 0);
|
|
41
|
+
--color-muted: oklch(22% 0 0);
|
|
42
|
+
--color-muted-foreground: oklch(60% 0 0);
|
|
43
|
+
--color-accent: oklch(25% 0 0);
|
|
44
|
+
--color-accent-foreground: oklch(95% 0 0);
|
|
45
|
+
--color-destructive: oklch(57.7% 0.245 27.325);
|
|
46
|
+
--color-destructive-foreground: oklch(98.5% 0 0);
|
|
47
|
+
--color-border: oklch(28% 0 0);
|
|
48
|
+
--color-input: oklch(28% 0 0);
|
|
49
|
+
--color-ring: oklch(80% 0 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Manual dark mode via .dark class */
|
|
54
|
+
:root.dark {
|
|
55
|
+
/* Dark theme - neutral with better contrast between sections */
|
|
56
|
+
--color-background: oklch(12% 0 0);
|
|
57
|
+
--color-foreground: oklch(95% 0 0);
|
|
58
|
+
--color-card: oklch(18% 0 0);
|
|
59
|
+
--color-card-foreground: oklch(95% 0 0);
|
|
60
|
+
--color-popover: oklch(18% 0 0);
|
|
61
|
+
--color-popover-foreground: oklch(95% 0 0);
|
|
62
|
+
--color-primary: oklch(95% 0 0);
|
|
63
|
+
--color-primary-foreground: oklch(12% 0 0);
|
|
64
|
+
--color-secondary: oklch(22% 0 0);
|
|
65
|
+
--color-secondary-foreground: oklch(95% 0 0);
|
|
66
|
+
--color-muted: oklch(22% 0 0);
|
|
67
|
+
--color-muted-foreground: oklch(60% 0 0);
|
|
68
|
+
--color-accent: oklch(25% 0 0);
|
|
69
|
+
--color-accent-foreground: oklch(95% 0 0);
|
|
70
|
+
--color-destructive: oklch(57.7% 0.245 27.325);
|
|
71
|
+
--color-destructive-foreground: oklch(98.5% 0 0);
|
|
72
|
+
--color-border: oklch(28% 0 0);
|
|
73
|
+
--color-input: oklch(28% 0 0);
|
|
74
|
+
--color-ring: oklch(80% 0 0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@layer base {
|
|
78
|
+
* {
|
|
79
|
+
@apply border-border;
|
|
80
|
+
}
|
|
81
|
+
body {
|
|
82
|
+
@apply bg-background text-foreground;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Custom scrollbar */
|
|
87
|
+
@layer utilities {
|
|
88
|
+
.scrollbar-thin {
|
|
89
|
+
scrollbar-width: thin;
|
|
90
|
+
scrollbar-color: oklch(50% 0 0 / 0.3) transparent;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.scrollbar-thin::-webkit-scrollbar {
|
|
94
|
+
width: 6px;
|
|
95
|
+
height: 6px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.scrollbar-thin::-webkit-scrollbar-track {
|
|
99
|
+
background: transparent;
|
|
100
|
+
border-radius: 3px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.scrollbar-thin::-webkit-scrollbar-thumb {
|
|
104
|
+
background: oklch(50% 0 0 / 0.3);
|
|
105
|
+
border-radius: 3px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
|
|
109
|
+
background: oklch(50% 0 0 / 0.5);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Code syntax highlighting for markdown */
|
|
114
|
+
@layer base {
|
|
115
|
+
/* Light theme code highlighting */
|
|
116
|
+
pre code.hljs {
|
|
117
|
+
display: block;
|
|
118
|
+
overflow-x: auto;
|
|
119
|
+
padding: 0;
|
|
120
|
+
background: transparent;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
code.hljs {
|
|
124
|
+
padding: 3px 5px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.hljs {
|
|
128
|
+
color: #24292e;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.hljs-comment,
|
|
132
|
+
.hljs-quote {
|
|
133
|
+
color: #6a737d;
|
|
134
|
+
font-style: italic;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.hljs-keyword,
|
|
138
|
+
.hljs-selector-tag,
|
|
139
|
+
.hljs-literal {
|
|
140
|
+
color: #d73a49;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.hljs-name,
|
|
144
|
+
.hljs-tag {
|
|
145
|
+
color: #22863a;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.hljs-attr,
|
|
149
|
+
.hljs-attribute {
|
|
150
|
+
color: #6f42c1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.hljs-variable,
|
|
154
|
+
.hljs-template-variable,
|
|
155
|
+
.hljs-regexp,
|
|
156
|
+
.hljs-link {
|
|
157
|
+
color: #005cc5;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.hljs-string,
|
|
161
|
+
.hljs-symbol,
|
|
162
|
+
.hljs-bullet {
|
|
163
|
+
color: #032f62;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.hljs-number {
|
|
167
|
+
color: #005cc5;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.hljs-meta,
|
|
171
|
+
.hljs-built_in,
|
|
172
|
+
.hljs-builtin-name,
|
|
173
|
+
.hljs-type,
|
|
174
|
+
.hljs-params {
|
|
175
|
+
color: #e36209;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.hljs-function .hljs-title {
|
|
179
|
+
color: #6f42c1;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.hljs-addition {
|
|
183
|
+
color: #22863a;
|
|
184
|
+
background-color: #f0fff4;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.hljs-deletion {
|
|
188
|
+
color: #b31d28;
|
|
189
|
+
background-color: #ffeef0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* Dark theme code highlighting */
|
|
193
|
+
.dark .hljs,
|
|
194
|
+
@media (prefers-color-scheme: dark) {
|
|
195
|
+
:root:not(.light) .hljs {
|
|
196
|
+
color: #e1e4e8;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:root:not(.light) .hljs-comment,
|
|
200
|
+
:root:not(.light) .hljs-quote {
|
|
201
|
+
color: #6a737d;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
:root:not(.light) .hljs-keyword,
|
|
205
|
+
:root:not(.light) .hljs-selector-tag,
|
|
206
|
+
:root:not(.light) .hljs-literal {
|
|
207
|
+
color: #ff7b72;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
:root:not(.light) .hljs-name,
|
|
211
|
+
:root:not(.light) .hljs-tag {
|
|
212
|
+
color: #7ee787;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
:root:not(.light) .hljs-attr,
|
|
216
|
+
:root:not(.light) .hljs-attribute {
|
|
217
|
+
color: #d2a8ff;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
:root:not(.light) .hljs-variable,
|
|
221
|
+
:root:not(.light) .hljs-template-variable,
|
|
222
|
+
:root:not(.light) .hljs-regexp,
|
|
223
|
+
:root:not(.light) .hljs-link {
|
|
224
|
+
color: #79c0ff;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
:root:not(.light) .hljs-string,
|
|
228
|
+
:root:not(.light) .hljs-symbol,
|
|
229
|
+
:root:not(.light) .hljs-bullet {
|
|
230
|
+
color: #a5d6ff;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
:root:not(.light) .hljs-number {
|
|
234
|
+
color: #79c0ff;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
:root:not(.light) .hljs-meta,
|
|
238
|
+
:root:not(.light) .hljs-built_in,
|
|
239
|
+
:root:not(.light) .hljs-builtin-name,
|
|
240
|
+
:root:not(.light) .hljs-type,
|
|
241
|
+
:root:not(.light) .hljs-params {
|
|
242
|
+
color: #ffa657;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
:root:not(.light) .hljs-function .hljs-title {
|
|
246
|
+
color: #d2a8ff;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
:root:not(.light) .hljs-addition {
|
|
250
|
+
color: #aff5b4;
|
|
251
|
+
background-color: #033a16;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
:root:not(.light) .hljs-deletion {
|
|
255
|
+
color: #ffdcd7;
|
|
256
|
+
background-color: #67060c;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.dark .hljs {
|
|
261
|
+
color: #e1e4e8;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.dark .hljs-comment,
|
|
265
|
+
.dark .hljs-quote {
|
|
266
|
+
color: #6a737d;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.dark .hljs-keyword,
|
|
270
|
+
.dark .hljs-selector-tag,
|
|
271
|
+
.dark .hljs-literal {
|
|
272
|
+
color: #ff7b72;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.dark .hljs-name,
|
|
276
|
+
.dark .hljs-tag {
|
|
277
|
+
color: #7ee787;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.dark .hljs-attr,
|
|
281
|
+
.dark .hljs-attribute {
|
|
282
|
+
color: #d2a8ff;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.dark .hljs-variable,
|
|
286
|
+
.dark .hljs-template-variable,
|
|
287
|
+
.dark .hljs-regexp,
|
|
288
|
+
.dark .hljs-link {
|
|
289
|
+
color: #79c0ff;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.dark .hljs-string,
|
|
293
|
+
.dark .hljs-symbol,
|
|
294
|
+
.dark .hljs-bullet {
|
|
295
|
+
color: #a5d6ff;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.dark .hljs-number {
|
|
299
|
+
color: #79c0ff;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.dark .hljs-meta,
|
|
303
|
+
.dark .hljs-built_in,
|
|
304
|
+
.dark .hljs-builtin-name,
|
|
305
|
+
.dark .hljs-type,
|
|
306
|
+
.dark .hljs-params {
|
|
307
|
+
color: #ffa657;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.dark .hljs-function .hljs-title {
|
|
311
|
+
color: #d2a8ff;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.dark .hljs-addition {
|
|
315
|
+
color: #aff5b4;
|
|
316
|
+
background-color: #033a16;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.dark .hljs-deletion {
|
|
320
|
+
color: #ffdcd7;
|
|
321
|
+
background-color: #67060c;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { Inter } from "next/font/google";
|
|
3
|
+
import "./globals.css";
|
|
4
|
+
|
|
5
|
+
const inter = Inter({ subsets: ["latin"] });
|
|
6
|
+
|
|
7
|
+
export const metadata: Metadata = {
|
|
8
|
+
title: "{{ cookiecutter.project_name }}",
|
|
9
|
+
description: "{{ cookiecutter.project_description }}",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function RootLayout({
|
|
13
|
+
children,
|
|
14
|
+
}: Readonly<{
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}>) {
|
|
17
|
+
return (
|
|
18
|
+
<html lang="en" suppressHydrationWarning>
|
|
19
|
+
<body className={inter.className}>{children}</body>
|
|
20
|
+
</html>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import { useState, type ReactNode } from "react";
|
|
5
|
+
import { ThemeProvider } from "@/components/theme";
|
|
6
|
+
|
|
7
|
+
interface ProvidersProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Providers({ children }: ProvidersProps) {
|
|
12
|
+
const [queryClient] = useState(
|
|
13
|
+
() =>
|
|
14
|
+
new QueryClient({
|
|
15
|
+
defaultOptions: {
|
|
16
|
+
queries: {
|
|
17
|
+
staleTime: 60 * 1000, // 1 minute
|
|
18
|
+
retry: 1,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<QueryClientProvider client={queryClient}>
|
|
26
|
+
<ThemeProvider>{children}</ThemeProvider>
|
|
27
|
+
</QueryClientProvider>
|
|
28
|
+
);
|
|
29
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/login-form.tsx
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useAuth } from "@/hooks";
|
|
6
|
+
import { Button, Input, Label, Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui";
|
|
7
|
+
import { ApiError } from "@/lib/api-client";
|
|
8
|
+
import { ROUTES } from "@/lib/constants";
|
|
9
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
10
|
+
import { GoogleIcon } from "@/components/icons/google-icon";
|
|
11
|
+
{%- endif %}
|
|
12
|
+
|
|
13
|
+
export function LoginForm() {
|
|
14
|
+
const { login } = useAuth();
|
|
15
|
+
const [email, setEmail] = useState("");
|
|
16
|
+
const [password, setPassword] = useState("");
|
|
17
|
+
const [error, setError] = useState("");
|
|
18
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
20
|
+
const [isOAuthLoading, setIsOAuthLoading] = useState(false);
|
|
21
|
+
{%- endif %}
|
|
22
|
+
|
|
23
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
setIsLoading(true);
|
|
26
|
+
setError("");
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await login({ email, password });
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err instanceof ApiError) {
|
|
32
|
+
setError(err.message);
|
|
33
|
+
} else {
|
|
34
|
+
setError("Login failed. Please try again.");
|
|
35
|
+
}
|
|
36
|
+
setIsLoading(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
41
|
+
|
|
42
|
+
const handleGoogleLogin = () => {
|
|
43
|
+
setIsOAuthLoading(true);
|
|
44
|
+
// Redirect to backend OAuth endpoint
|
|
45
|
+
window.location.href = `${process.env.NEXT_PUBLIC_API_URL}/api/v1/oauth/google/login`;
|
|
46
|
+
};
|
|
47
|
+
{%- endif %}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Card className="w-full max-w-md mx-auto">
|
|
51
|
+
<CardHeader>
|
|
52
|
+
<CardTitle className="text-2xl text-center">Login</CardTitle>
|
|
53
|
+
</CardHeader>
|
|
54
|
+
<CardContent>
|
|
55
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
56
|
+
<div className="space-y-2">
|
|
57
|
+
<Label htmlFor="email">Email</Label>
|
|
58
|
+
<Input
|
|
59
|
+
id="email"
|
|
60
|
+
type="email"
|
|
61
|
+
placeholder="you@example.com"
|
|
62
|
+
value={email}
|
|
63
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
64
|
+
required
|
|
65
|
+
disabled={isLoading}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="space-y-2">
|
|
69
|
+
<Label htmlFor="password">Password</Label>
|
|
70
|
+
<Input
|
|
71
|
+
id="password"
|
|
72
|
+
type="password"
|
|
73
|
+
value={password}
|
|
74
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
75
|
+
required
|
|
76
|
+
disabled={isLoading}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
{error && (
|
|
80
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
81
|
+
)}
|
|
82
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
83
|
+
{isLoading ? "Logging in..." : "Login"}
|
|
84
|
+
</Button>
|
|
85
|
+
</form>
|
|
86
|
+
|
|
87
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
88
|
+
|
|
89
|
+
<div className="relative my-6">
|
|
90
|
+
<div className="absolute inset-0 flex items-center">
|
|
91
|
+
<span className="w-full border-t" />
|
|
92
|
+
</div>
|
|
93
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
94
|
+
<span className="bg-card px-2 text-muted-foreground">Or continue with</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<Button
|
|
99
|
+
type="button"
|
|
100
|
+
variant="outline"
|
|
101
|
+
className="w-full"
|
|
102
|
+
onClick={handleGoogleLogin}
|
|
103
|
+
disabled={isOAuthLoading || isLoading}
|
|
104
|
+
>
|
|
105
|
+
<GoogleIcon className="mr-2 h-4 w-4" />
|
|
106
|
+
{isOAuthLoading ? "Redirecting..." : "Continue with Google"}
|
|
107
|
+
</Button>
|
|
108
|
+
{%- endif %}
|
|
109
|
+
</CardContent>
|
|
110
|
+
<CardFooter className="justify-center">
|
|
111
|
+
<p className="text-sm text-muted-foreground">
|
|
112
|
+
Don't have an account?{" "}
|
|
113
|
+
<Link href={ROUTES.REGISTER} className="text-primary hover:underline">
|
|
114
|
+
Register
|
|
115
|
+
</Link>
|
|
116
|
+
</p>
|
|
117
|
+
</CardFooter>
|
|
118
|
+
</Card>
|
|
119
|
+
);
|
|
120
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/register-form.tsx
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { useAuth } from "@/hooks";
|
|
7
|
+
import { Button, Input, Label, Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui";
|
|
8
|
+
import { ApiError } from "@/lib/api-client";
|
|
9
|
+
import { ROUTES } from "@/lib/constants";
|
|
10
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
11
|
+
import { GoogleIcon } from "@/components/icons/google-icon";
|
|
12
|
+
{%- endif %}
|
|
13
|
+
|
|
14
|
+
export function RegisterForm() {
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
const { register } = useAuth();
|
|
17
|
+
const [email, setEmail] = useState("");
|
|
18
|
+
const [password, setPassword] = useState("");
|
|
19
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
20
|
+
const [name, setName] = useState("");
|
|
21
|
+
const [error, setError] = useState("");
|
|
22
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
23
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
24
|
+
const [isOAuthLoading, setIsOAuthLoading] = useState(false);
|
|
25
|
+
{%- endif %}
|
|
26
|
+
|
|
27
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
setError("");
|
|
30
|
+
|
|
31
|
+
if (password !== confirmPassword) {
|
|
32
|
+
setError("Passwords do not match");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setIsLoading(true);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await register({ email, password, name: name || undefined });
|
|
40
|
+
router.push(ROUTES.LOGIN + "?registered=true");
|
|
41
|
+
} catch (err) {
|
|
42
|
+
if (err instanceof ApiError) {
|
|
43
|
+
setError(err.message);
|
|
44
|
+
} else {
|
|
45
|
+
setError("Registration failed. Please try again.");
|
|
46
|
+
}
|
|
47
|
+
} finally {
|
|
48
|
+
setIsLoading(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
53
|
+
|
|
54
|
+
const handleGoogleSignUp = () => {
|
|
55
|
+
setIsOAuthLoading(true);
|
|
56
|
+
// Redirect to backend OAuth endpoint
|
|
57
|
+
window.location.href = `${process.env.NEXT_PUBLIC_API_URL}/api/v1/oauth/google/login`;
|
|
58
|
+
};
|
|
59
|
+
{%- endif %}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Card className="w-full max-w-md mx-auto">
|
|
63
|
+
<CardHeader>
|
|
64
|
+
<CardTitle className="text-2xl text-center">Create Account</CardTitle>
|
|
65
|
+
</CardHeader>
|
|
66
|
+
<CardContent>
|
|
67
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
68
|
+
<Button
|
|
69
|
+
type="button"
|
|
70
|
+
variant="outline"
|
|
71
|
+
className="w-full mb-6"
|
|
72
|
+
onClick={handleGoogleSignUp}
|
|
73
|
+
disabled={isOAuthLoading || isLoading}
|
|
74
|
+
>
|
|
75
|
+
<GoogleIcon className="mr-2 h-4 w-4" />
|
|
76
|
+
{isOAuthLoading ? "Redirecting..." : "Sign up with Google"}
|
|
77
|
+
</Button>
|
|
78
|
+
|
|
79
|
+
<div className="relative mb-6">
|
|
80
|
+
<div className="absolute inset-0 flex items-center">
|
|
81
|
+
<span className="w-full border-t" />
|
|
82
|
+
</div>
|
|
83
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
84
|
+
<span className="bg-card px-2 text-muted-foreground">Or register with email</span>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
{%- endif %}
|
|
88
|
+
|
|
89
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
90
|
+
<div className="space-y-2">
|
|
91
|
+
<Label htmlFor="name">Name (optional)</Label>
|
|
92
|
+
<Input
|
|
93
|
+
id="name"
|
|
94
|
+
type="text"
|
|
95
|
+
placeholder="John Doe"
|
|
96
|
+
value={name}
|
|
97
|
+
onChange={(e) => setName(e.target.value)}
|
|
98
|
+
disabled={isLoading}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="space-y-2">
|
|
102
|
+
<Label htmlFor="email">Email</Label>
|
|
103
|
+
<Input
|
|
104
|
+
id="email"
|
|
105
|
+
type="email"
|
|
106
|
+
placeholder="you@example.com"
|
|
107
|
+
value={email}
|
|
108
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
109
|
+
required
|
|
110
|
+
disabled={isLoading}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="space-y-2">
|
|
114
|
+
<Label htmlFor="password">Password</Label>
|
|
115
|
+
<Input
|
|
116
|
+
id="password"
|
|
117
|
+
type="password"
|
|
118
|
+
value={password}
|
|
119
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
120
|
+
required
|
|
121
|
+
disabled={isLoading}
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
<div className="space-y-2">
|
|
125
|
+
<Label htmlFor="confirmPassword">Confirm Password</Label>
|
|
126
|
+
<Input
|
|
127
|
+
id="confirmPassword"
|
|
128
|
+
type="password"
|
|
129
|
+
value={confirmPassword}
|
|
130
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
131
|
+
required
|
|
132
|
+
disabled={isLoading}
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
{error && (
|
|
136
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
137
|
+
)}
|
|
138
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
139
|
+
{isLoading ? "Creating account..." : "Register"}
|
|
140
|
+
</Button>
|
|
141
|
+
</form>
|
|
142
|
+
</CardContent>
|
|
143
|
+
<CardFooter className="justify-center">
|
|
144
|
+
<p className="text-sm text-muted-foreground">
|
|
145
|
+
Already have an account?{" "}
|
|
146
|
+
<Link href={ROUTES.LOGIN} className="text-primary hover:underline">
|
|
147
|
+
Login
|
|
148
|
+
</Link>
|
|
149
|
+
</p>
|
|
150
|
+
</CardFooter>
|
|
151
|
+
</Card>
|
|
152
|
+
);
|
|
153
|
+
}
|