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,477 @@
|
|
|
1
|
+
{%- if cookiecutter.enable_webhooks and cookiecutter.use_database %}
|
|
2
|
+
"""Webhook management routes."""
|
|
3
|
+
|
|
4
|
+
from fastapi import APIRouter, Query, status
|
|
5
|
+
{%- if cookiecutter.use_postgresql %}
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
{%- endif %}
|
|
8
|
+
|
|
9
|
+
from app.api.deps import WebhookSvc
|
|
10
|
+
{%- if cookiecutter.use_jwt %}
|
|
11
|
+
from app.api.deps import CurrentUser
|
|
12
|
+
{%- endif %}
|
|
13
|
+
from app.schemas.webhook import (
|
|
14
|
+
WebhookCreate,
|
|
15
|
+
WebhookDeliveryListResponse,
|
|
16
|
+
WebhookListResponse,
|
|
17
|
+
WebhookRead,
|
|
18
|
+
WebhookTestResponse,
|
|
19
|
+
WebhookUpdate,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
router = APIRouter()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
{%- if cookiecutter.use_postgresql %}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@router.post("", response_model=WebhookRead, status_code=status.HTTP_201_CREATED)
|
|
29
|
+
async def create_webhook(
|
|
30
|
+
data: WebhookCreate,
|
|
31
|
+
webhook_service: WebhookSvc,
|
|
32
|
+
{%- if cookiecutter.use_jwt %}
|
|
33
|
+
current_user: CurrentUser,
|
|
34
|
+
{%- endif %}
|
|
35
|
+
):
|
|
36
|
+
"""Create a new webhook subscription."""
|
|
37
|
+
webhook = await webhook_service.create_webhook(
|
|
38
|
+
data,
|
|
39
|
+
{%- if cookiecutter.use_jwt %}
|
|
40
|
+
user_id=current_user.id,
|
|
41
|
+
{%- endif %}
|
|
42
|
+
)
|
|
43
|
+
return WebhookRead(
|
|
44
|
+
id=webhook.id,
|
|
45
|
+
name=webhook.name,
|
|
46
|
+
url=webhook.url,
|
|
47
|
+
events=webhook.events,
|
|
48
|
+
is_active=webhook.is_active,
|
|
49
|
+
description=webhook.description,
|
|
50
|
+
created_at=webhook.created_at,
|
|
51
|
+
updated_at=webhook.updated_at,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@router.get("", response_model=WebhookListResponse)
|
|
56
|
+
async def list_webhooks(
|
|
57
|
+
webhook_service: WebhookSvc,
|
|
58
|
+
{%- if cookiecutter.use_jwt %}
|
|
59
|
+
current_user: CurrentUser,
|
|
60
|
+
{%- endif %}
|
|
61
|
+
skip: int = Query(0, ge=0),
|
|
62
|
+
limit: int = Query(50, ge=1, le=100),
|
|
63
|
+
):
|
|
64
|
+
"""List all webhooks."""
|
|
65
|
+
webhooks, total = await webhook_service.list_webhooks(
|
|
66
|
+
{%- if cookiecutter.use_jwt %}
|
|
67
|
+
user_id=current_user.id,
|
|
68
|
+
{%- endif %}
|
|
69
|
+
skip=skip,
|
|
70
|
+
limit=limit,
|
|
71
|
+
)
|
|
72
|
+
return WebhookListResponse(
|
|
73
|
+
items=[
|
|
74
|
+
WebhookRead(
|
|
75
|
+
id=w.id,
|
|
76
|
+
name=w.name,
|
|
77
|
+
url=w.url,
|
|
78
|
+
events=w.events,
|
|
79
|
+
is_active=w.is_active,
|
|
80
|
+
description=w.description,
|
|
81
|
+
created_at=w.created_at,
|
|
82
|
+
updated_at=w.updated_at,
|
|
83
|
+
)
|
|
84
|
+
for w in webhooks
|
|
85
|
+
],
|
|
86
|
+
total=total,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@router.get("/{webhook_id}", response_model=WebhookRead)
|
|
91
|
+
async def get_webhook(
|
|
92
|
+
webhook_id: UUID,
|
|
93
|
+
webhook_service: WebhookSvc,
|
|
94
|
+
):
|
|
95
|
+
"""Get a webhook by ID."""
|
|
96
|
+
webhook = await webhook_service.get_webhook(webhook_id)
|
|
97
|
+
return WebhookRead(
|
|
98
|
+
id=webhook.id,
|
|
99
|
+
name=webhook.name,
|
|
100
|
+
url=webhook.url,
|
|
101
|
+
events=webhook.events,
|
|
102
|
+
is_active=webhook.is_active,
|
|
103
|
+
description=webhook.description,
|
|
104
|
+
created_at=webhook.created_at,
|
|
105
|
+
updated_at=webhook.updated_at,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@router.patch("/{webhook_id}", response_model=WebhookRead)
|
|
110
|
+
async def update_webhook(
|
|
111
|
+
webhook_id: UUID,
|
|
112
|
+
data: WebhookUpdate,
|
|
113
|
+
webhook_service: WebhookSvc,
|
|
114
|
+
):
|
|
115
|
+
"""Update a webhook."""
|
|
116
|
+
webhook = await webhook_service.update_webhook(webhook_id, data)
|
|
117
|
+
return WebhookRead(
|
|
118
|
+
id=webhook.id,
|
|
119
|
+
name=webhook.name,
|
|
120
|
+
url=webhook.url,
|
|
121
|
+
events=webhook.events,
|
|
122
|
+
is_active=webhook.is_active,
|
|
123
|
+
description=webhook.description,
|
|
124
|
+
created_at=webhook.created_at,
|
|
125
|
+
updated_at=webhook.updated_at,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@router.delete("/{webhook_id}", status_code=status.HTTP_204_NO_CONTENT)
|
|
130
|
+
async def delete_webhook(
|
|
131
|
+
webhook_id: UUID,
|
|
132
|
+
webhook_service: WebhookSvc,
|
|
133
|
+
):
|
|
134
|
+
"""Delete a webhook."""
|
|
135
|
+
await webhook_service.delete_webhook(webhook_id)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@router.post("/{webhook_id}/test", response_model=WebhookTestResponse)
|
|
139
|
+
async def test_webhook(
|
|
140
|
+
webhook_id: UUID,
|
|
141
|
+
webhook_service: WebhookSvc,
|
|
142
|
+
):
|
|
143
|
+
"""Send a test event to the webhook."""
|
|
144
|
+
result = await webhook_service.test_webhook(webhook_id)
|
|
145
|
+
return WebhookTestResponse(**result)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@router.post("/{webhook_id}/regenerate-secret")
|
|
149
|
+
async def regenerate_webhook_secret(
|
|
150
|
+
webhook_id: UUID,
|
|
151
|
+
webhook_service: WebhookSvc,
|
|
152
|
+
):
|
|
153
|
+
"""Regenerate the webhook secret."""
|
|
154
|
+
new_secret = await webhook_service.regenerate_secret(webhook_id)
|
|
155
|
+
return {"secret": new_secret}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@router.get("/{webhook_id}/deliveries", response_model=WebhookDeliveryListResponse)
|
|
159
|
+
async def list_webhook_deliveries(
|
|
160
|
+
webhook_id: UUID,
|
|
161
|
+
webhook_service: WebhookSvc,
|
|
162
|
+
skip: int = Query(0, ge=0),
|
|
163
|
+
limit: int = Query(50, ge=1, le=100),
|
|
164
|
+
):
|
|
165
|
+
"""Get delivery history for a webhook."""
|
|
166
|
+
from app.schemas.webhook import WebhookDeliveryRead
|
|
167
|
+
|
|
168
|
+
deliveries, total = await webhook_service.get_deliveries(webhook_id, skip=skip, limit=limit)
|
|
169
|
+
return WebhookDeliveryListResponse(
|
|
170
|
+
items=[
|
|
171
|
+
WebhookDeliveryRead(
|
|
172
|
+
id=d.id,
|
|
173
|
+
webhook_id=d.webhook_id,
|
|
174
|
+
event_type=d.event_type,
|
|
175
|
+
response_status=d.response_status,
|
|
176
|
+
error_message=d.error_message,
|
|
177
|
+
attempt_count=d.attempt_count,
|
|
178
|
+
success=d.success,
|
|
179
|
+
created_at=d.created_at,
|
|
180
|
+
delivered_at=d.delivered_at,
|
|
181
|
+
)
|
|
182
|
+
for d in deliveries
|
|
183
|
+
],
|
|
184
|
+
total=total,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
{%- elif cookiecutter.use_sqlite %}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@router.post("", response_model=WebhookRead, status_code=status.HTTP_201_CREATED)
|
|
192
|
+
def create_webhook(
|
|
193
|
+
data: WebhookCreate,
|
|
194
|
+
webhook_service: WebhookSvc,
|
|
195
|
+
{%- if cookiecutter.use_jwt %}
|
|
196
|
+
current_user: CurrentUser,
|
|
197
|
+
{%- endif %}
|
|
198
|
+
):
|
|
199
|
+
"""Create a new webhook subscription."""
|
|
200
|
+
webhook = webhook_service.create_webhook(
|
|
201
|
+
data,
|
|
202
|
+
{%- if cookiecutter.use_jwt %}
|
|
203
|
+
user_id=current_user.id,
|
|
204
|
+
{%- endif %}
|
|
205
|
+
)
|
|
206
|
+
return WebhookRead(
|
|
207
|
+
id=webhook.id,
|
|
208
|
+
name=webhook.name,
|
|
209
|
+
url=webhook.url,
|
|
210
|
+
events=webhook.events,
|
|
211
|
+
is_active=webhook.is_active,
|
|
212
|
+
description=webhook.description,
|
|
213
|
+
created_at=webhook.created_at,
|
|
214
|
+
updated_at=webhook.updated_at,
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@router.get("", response_model=WebhookListResponse)
|
|
219
|
+
def list_webhooks(
|
|
220
|
+
webhook_service: WebhookSvc,
|
|
221
|
+
{%- if cookiecutter.use_jwt %}
|
|
222
|
+
current_user: CurrentUser,
|
|
223
|
+
{%- endif %}
|
|
224
|
+
skip: int = Query(0, ge=0),
|
|
225
|
+
limit: int = Query(50, ge=1, le=100),
|
|
226
|
+
):
|
|
227
|
+
"""List all webhooks."""
|
|
228
|
+
webhooks, total = webhook_service.list_webhooks(
|
|
229
|
+
{%- if cookiecutter.use_jwt %}
|
|
230
|
+
user_id=current_user.id,
|
|
231
|
+
{%- endif %}
|
|
232
|
+
skip=skip,
|
|
233
|
+
limit=limit,
|
|
234
|
+
)
|
|
235
|
+
return WebhookListResponse(
|
|
236
|
+
items=[
|
|
237
|
+
WebhookRead(
|
|
238
|
+
id=w.id,
|
|
239
|
+
name=w.name,
|
|
240
|
+
url=w.url,
|
|
241
|
+
events=w.events,
|
|
242
|
+
is_active=w.is_active,
|
|
243
|
+
description=w.description,
|
|
244
|
+
created_at=w.created_at,
|
|
245
|
+
updated_at=w.updated_at,
|
|
246
|
+
)
|
|
247
|
+
for w in webhooks
|
|
248
|
+
],
|
|
249
|
+
total=total,
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@router.get("/{webhook_id}", response_model=WebhookRead)
|
|
254
|
+
def get_webhook(
|
|
255
|
+
webhook_id: str,
|
|
256
|
+
webhook_service: WebhookSvc,
|
|
257
|
+
):
|
|
258
|
+
"""Get a webhook by ID."""
|
|
259
|
+
webhook = webhook_service.get_webhook(webhook_id)
|
|
260
|
+
return WebhookRead(
|
|
261
|
+
id=webhook.id,
|
|
262
|
+
name=webhook.name,
|
|
263
|
+
url=webhook.url,
|
|
264
|
+
events=webhook.events,
|
|
265
|
+
is_active=webhook.is_active,
|
|
266
|
+
description=webhook.description,
|
|
267
|
+
created_at=webhook.created_at,
|
|
268
|
+
updated_at=webhook.updated_at,
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
@router.patch("/{webhook_id}", response_model=WebhookRead)
|
|
273
|
+
def update_webhook(
|
|
274
|
+
webhook_id: str,
|
|
275
|
+
data: WebhookUpdate,
|
|
276
|
+
webhook_service: WebhookSvc,
|
|
277
|
+
):
|
|
278
|
+
"""Update a webhook."""
|
|
279
|
+
webhook = webhook_service.update_webhook(webhook_id, data)
|
|
280
|
+
return WebhookRead(
|
|
281
|
+
id=webhook.id,
|
|
282
|
+
name=webhook.name,
|
|
283
|
+
url=webhook.url,
|
|
284
|
+
events=webhook.events,
|
|
285
|
+
is_active=webhook.is_active,
|
|
286
|
+
description=webhook.description,
|
|
287
|
+
created_at=webhook.created_at,
|
|
288
|
+
updated_at=webhook.updated_at,
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@router.delete("/{webhook_id}", status_code=status.HTTP_204_NO_CONTENT)
|
|
293
|
+
def delete_webhook(
|
|
294
|
+
webhook_id: str,
|
|
295
|
+
webhook_service: WebhookSvc,
|
|
296
|
+
):
|
|
297
|
+
"""Delete a webhook."""
|
|
298
|
+
webhook_service.delete_webhook(webhook_id)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
@router.get("/{webhook_id}/deliveries", response_model=WebhookDeliveryListResponse)
|
|
302
|
+
def list_webhook_deliveries(
|
|
303
|
+
webhook_id: str,
|
|
304
|
+
webhook_service: WebhookSvc,
|
|
305
|
+
skip: int = Query(0, ge=0),
|
|
306
|
+
limit: int = Query(50, ge=1, le=100),
|
|
307
|
+
):
|
|
308
|
+
"""Get delivery history for a webhook."""
|
|
309
|
+
from app.schemas.webhook import WebhookDeliveryRead
|
|
310
|
+
|
|
311
|
+
deliveries, total = webhook_service.get_deliveries(webhook_id, skip=skip, limit=limit)
|
|
312
|
+
return WebhookDeliveryListResponse(
|
|
313
|
+
items=[
|
|
314
|
+
WebhookDeliveryRead(
|
|
315
|
+
id=d.id,
|
|
316
|
+
webhook_id=d.webhook_id,
|
|
317
|
+
event_type=d.event_type,
|
|
318
|
+
response_status=d.response_status,
|
|
319
|
+
error_message=d.error_message,
|
|
320
|
+
attempt_count=d.attempt_count,
|
|
321
|
+
success=d.success,
|
|
322
|
+
created_at=d.created_at,
|
|
323
|
+
delivered_at=d.delivered_at,
|
|
324
|
+
)
|
|
325
|
+
for d in deliveries
|
|
326
|
+
],
|
|
327
|
+
total=total,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
{%- elif cookiecutter.use_mongodb %}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@router.post("", response_model=WebhookRead, status_code=status.HTTP_201_CREATED)
|
|
335
|
+
async def create_webhook(
|
|
336
|
+
data: WebhookCreate,
|
|
337
|
+
webhook_service: WebhookSvc,
|
|
338
|
+
{%- if cookiecutter.use_jwt %}
|
|
339
|
+
current_user: CurrentUser,
|
|
340
|
+
{%- endif %}
|
|
341
|
+
):
|
|
342
|
+
"""Create a new webhook subscription."""
|
|
343
|
+
webhook = await webhook_service.create_webhook(
|
|
344
|
+
data,
|
|
345
|
+
{%- if cookiecutter.use_jwt %}
|
|
346
|
+
user_id=str(current_user.id),
|
|
347
|
+
{%- endif %}
|
|
348
|
+
)
|
|
349
|
+
return WebhookRead(
|
|
350
|
+
id=str(webhook.id),
|
|
351
|
+
name=webhook.name,
|
|
352
|
+
url=webhook.url,
|
|
353
|
+
events=webhook.events,
|
|
354
|
+
is_active=webhook.is_active,
|
|
355
|
+
description=webhook.description,
|
|
356
|
+
created_at=webhook.created_at,
|
|
357
|
+
updated_at=webhook.updated_at or webhook.created_at,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
@router.get("", response_model=WebhookListResponse)
|
|
362
|
+
async def list_webhooks(
|
|
363
|
+
webhook_service: WebhookSvc,
|
|
364
|
+
{%- if cookiecutter.use_jwt %}
|
|
365
|
+
current_user: CurrentUser,
|
|
366
|
+
{%- endif %}
|
|
367
|
+
skip: int = Query(0, ge=0),
|
|
368
|
+
limit: int = Query(50, ge=1, le=100),
|
|
369
|
+
):
|
|
370
|
+
"""List all webhooks."""
|
|
371
|
+
webhooks, total = await webhook_service.list_webhooks(
|
|
372
|
+
{%- if cookiecutter.use_jwt %}
|
|
373
|
+
user_id=str(current_user.id),
|
|
374
|
+
{%- endif %}
|
|
375
|
+
skip=skip,
|
|
376
|
+
limit=limit,
|
|
377
|
+
)
|
|
378
|
+
return WebhookListResponse(
|
|
379
|
+
items=[
|
|
380
|
+
WebhookRead(
|
|
381
|
+
id=str(w.id),
|
|
382
|
+
name=w.name,
|
|
383
|
+
url=w.url,
|
|
384
|
+
events=w.events,
|
|
385
|
+
is_active=w.is_active,
|
|
386
|
+
description=w.description,
|
|
387
|
+
created_at=w.created_at,
|
|
388
|
+
updated_at=w.updated_at or w.created_at,
|
|
389
|
+
)
|
|
390
|
+
for w in webhooks
|
|
391
|
+
],
|
|
392
|
+
total=total,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@router.get("/{webhook_id}", response_model=WebhookRead)
|
|
397
|
+
async def get_webhook(
|
|
398
|
+
webhook_id: str,
|
|
399
|
+
webhook_service: WebhookSvc,
|
|
400
|
+
):
|
|
401
|
+
"""Get a webhook by ID."""
|
|
402
|
+
webhook = await webhook_service.get_webhook(webhook_id)
|
|
403
|
+
return WebhookRead(
|
|
404
|
+
id=str(webhook.id),
|
|
405
|
+
name=webhook.name,
|
|
406
|
+
url=webhook.url,
|
|
407
|
+
events=webhook.events,
|
|
408
|
+
is_active=webhook.is_active,
|
|
409
|
+
description=webhook.description,
|
|
410
|
+
created_at=webhook.created_at,
|
|
411
|
+
updated_at=webhook.updated_at or webhook.created_at,
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
@router.patch("/{webhook_id}", response_model=WebhookRead)
|
|
416
|
+
async def update_webhook(
|
|
417
|
+
webhook_id: str,
|
|
418
|
+
data: WebhookUpdate,
|
|
419
|
+
webhook_service: WebhookSvc,
|
|
420
|
+
):
|
|
421
|
+
"""Update a webhook."""
|
|
422
|
+
webhook = await webhook_service.update_webhook(webhook_id, data)
|
|
423
|
+
return WebhookRead(
|
|
424
|
+
id=str(webhook.id),
|
|
425
|
+
name=webhook.name,
|
|
426
|
+
url=webhook.url,
|
|
427
|
+
events=webhook.events,
|
|
428
|
+
is_active=webhook.is_active,
|
|
429
|
+
description=webhook.description,
|
|
430
|
+
created_at=webhook.created_at,
|
|
431
|
+
updated_at=webhook.updated_at or webhook.created_at,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
@router.delete("/{webhook_id}", status_code=status.HTTP_204_NO_CONTENT)
|
|
436
|
+
async def delete_webhook(
|
|
437
|
+
webhook_id: str,
|
|
438
|
+
webhook_service: WebhookSvc,
|
|
439
|
+
):
|
|
440
|
+
"""Delete a webhook."""
|
|
441
|
+
await webhook_service.delete_webhook(webhook_id)
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
@router.get("/{webhook_id}/deliveries", response_model=WebhookDeliveryListResponse)
|
|
445
|
+
async def list_webhook_deliveries(
|
|
446
|
+
webhook_id: str,
|
|
447
|
+
webhook_service: WebhookSvc,
|
|
448
|
+
skip: int = Query(0, ge=0),
|
|
449
|
+
limit: int = Query(50, ge=1, le=100),
|
|
450
|
+
):
|
|
451
|
+
"""Get delivery history for a webhook."""
|
|
452
|
+
from app.schemas.webhook import WebhookDeliveryRead
|
|
453
|
+
|
|
454
|
+
deliveries, total = await webhook_service.get_deliveries(webhook_id, skip=skip, limit=limit)
|
|
455
|
+
return WebhookDeliveryListResponse(
|
|
456
|
+
items=[
|
|
457
|
+
WebhookDeliveryRead(
|
|
458
|
+
id=str(d.id),
|
|
459
|
+
webhook_id=d.webhook_id,
|
|
460
|
+
event_type=d.event_type,
|
|
461
|
+
response_status=d.response_status,
|
|
462
|
+
error_message=d.error_message,
|
|
463
|
+
attempt_count=d.attempt_count,
|
|
464
|
+
success=d.success,
|
|
465
|
+
created_at=d.created_at,
|
|
466
|
+
delivered_at=d.delivered_at,
|
|
467
|
+
)
|
|
468
|
+
for d in deliveries
|
|
469
|
+
],
|
|
470
|
+
total=total,
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
{%- endif %}
|
|
475
|
+
{%- else %}
|
|
476
|
+
"""Webhook routes - not configured."""
|
|
477
|
+
{%- endif %}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{%- if cookiecutter.enable_websockets %}
|
|
2
|
+
"""WebSocket routes."""
|
|
3
|
+
|
|
4
|
+
from fastapi import APIRouter, WebSocket
|
|
5
|
+
|
|
6
|
+
router = APIRouter()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ConnectionManager:
|
|
10
|
+
"""WebSocket connection manager."""
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.active_connections: list[WebSocket] = []
|
|
14
|
+
|
|
15
|
+
async def connect(self, websocket: WebSocket) -> None:
|
|
16
|
+
"""Accept and store a new WebSocket connection."""
|
|
17
|
+
await websocket.accept()
|
|
18
|
+
self.active_connections.append(websocket)
|
|
19
|
+
|
|
20
|
+
def disconnect(self, websocket: WebSocket) -> None:
|
|
21
|
+
"""Remove a WebSocket connection."""
|
|
22
|
+
self.active_connections.remove(websocket)
|
|
23
|
+
|
|
24
|
+
async def send_personal_message(self, message: str, websocket: WebSocket) -> None:
|
|
25
|
+
"""Send a message to a specific WebSocket."""
|
|
26
|
+
await websocket.send_text(message)
|
|
27
|
+
|
|
28
|
+
async def broadcast(self, message: str) -> None:
|
|
29
|
+
"""Broadcast a message to all connected WebSockets."""
|
|
30
|
+
for connection in self.active_connections:
|
|
31
|
+
await connection.send_text(message)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
manager = ConnectionManager()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@router.websocket("/ws")
|
|
38
|
+
async def websocket_endpoint(websocket: WebSocket):
|
|
39
|
+
"""WebSocket endpoint for real-time communication."""
|
|
40
|
+
await manager.connect(websocket)
|
|
41
|
+
async for data in websocket.iter_text():
|
|
42
|
+
await manager.broadcast(f"Message: {data}")
|
|
43
|
+
manager.disconnect(websocket)
|
|
44
|
+
{%- else %}
|
|
45
|
+
"""WebSocket - not configured."""
|
|
46
|
+
{%- endif %}
|