baldart 3.6.2
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.
- package/CHANGELOG.md +599 -0
- package/README.md +566 -0
- package/VERSION +1 -0
- package/bin/baldart.js +143 -0
- package/framework/.claude/agents/REGISTRY.md +169 -0
- package/framework/.claude/agents/api-perf-cost-auditor.md +291 -0
- package/framework/.claude/agents/code-reviewer.md +350 -0
- package/framework/.claude/agents/codebase-architect.md +391 -0
- package/framework/.claude/agents/coder.md +291 -0
- package/framework/.claude/agents/deep-human-insight.md +198 -0
- package/framework/.claude/agents/doc-reviewer.md +440 -0
- package/framework/.claude/agents/email-deliverability-architect.md +193 -0
- package/framework/.claude/agents/hybrid-ml-architect.md +285 -0
- package/framework/.claude/agents/hyper-gamification-designer.md +149 -0
- package/framework/.claude/agents/legal-counsel-gdpr.md +179 -0
- package/framework/.claude/agents/marketing-conversion-strategist.md +162 -0
- package/framework/.claude/agents/motion-expert.md +108 -0
- package/framework/.claude/agents/onboarding-architect-lead.md +230 -0
- package/framework/.claude/agents/plan-auditor.md +546 -0
- package/framework/.claude/agents/prd-card-writer.md +372 -0
- package/framework/.claude/agents/prd.md +744 -0
- package/framework/.claude/agents/qa-sentinel.md +305 -0
- package/framework/.claude/agents/remotion-animator-orchestrator.md +218 -0
- package/framework/.claude/agents/security-reviewer.md +276 -0
- package/framework/.claude/agents/senior-researcher.md +175 -0
- package/framework/.claude/agents/seo-analytics-strategist.md +156 -0
- package/framework/.claude/agents/skill-improver.md +61 -0
- package/framework/.claude/agents/ui-expert.md +191 -0
- package/framework/.claude/agents/visual-designer.md +190 -0
- package/framework/.claude/agents/website-orchestrator.md +118 -0
- package/framework/.claude/agents/wiki-curator.md +145 -0
- package/framework/.claude/commands/baldart-push.md +15 -0
- package/framework/.claude/commands/check.md +237 -0
- package/framework/.claude/commands/codexreview.md +203 -0
- package/framework/.claude/commands/design-review.md +11 -0
- package/framework/.claude/commands/issue-review.md +34 -0
- package/framework/.claude/commands/new.md +331 -0
- package/framework/.claude/commands/qa.md +257 -0
- package/framework/.claude/hooks/framework-edit-gate.js +208 -0
- package/framework/.claude/hooks/lint-before-commit.sh.template +66 -0
- package/framework/.claude/settings.local.json.example +32 -0
- package/framework/.claude/skills/api-design-principles/SKILL.md +567 -0
- package/framework/.claude/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/framework/.claude/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/framework/.claude/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/framework/.claude/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/framework/.claude/skills/baldart-push/SKILL.md +222 -0
- package/framework/.claude/skills/bug/SKILL.md +200 -0
- package/framework/.claude/skills/bug/references/logging-patterns.md +174 -0
- package/framework/.claude/skills/capture/SKILL.md +125 -0
- package/framework/.claude/skills/capture/references/synthesis-template.md +42 -0
- package/framework/.claude/skills/context-primer/SKILL.md +189 -0
- package/framework/.claude/skills/copywriting/SKILL.md +273 -0
- package/framework/.claude/skills/copywriting/references/copy-frameworks.md +338 -0
- package/framework/.claude/skills/copywriting/references/natural-transitions.md +252 -0
- package/framework/.claude/skills/doc-writing-for-rag/SKILL.md +119 -0
- package/framework/.claude/skills/doc-writing-for-rag/references/before-after-examples.md +291 -0
- package/framework/.claude/skills/doc-writing-for-rag/references/compact-templates.md +183 -0
- package/framework/.claude/skills/doc-writing-for-rag/references/frontmatter-minimal.md +112 -0
- package/framework/.claude/skills/doc-writing-for-rag/references/line-count-targets.md +110 -0
- package/framework/.claude/skills/doc-writing-for-rag/references/schemas-and-errors.md +129 -0
- package/framework/.claude/skills/find-skills/SKILL.md +133 -0
- package/framework/.claude/skills/frontend-design/LICENSE.txt +177 -0
- package/framework/.claude/skills/frontend-design/SKILL.md +84 -0
- package/framework/.claude/skills/gamification-design/SKILL.md +130 -0
- package/framework/.claude/skills/issue-review/SKILL.md +45 -0
- package/framework/.claude/skills/kie-ai/SKILL.md +262 -0
- package/framework/.claude/skills/kie-ai/references/models-catalog.md +272 -0
- package/framework/.claude/skills/kie-ai/scripts/kie_api.sh +209 -0
- package/framework/.claude/skills/kie-ai/scripts/remove_greenscreen.py +69 -0
- package/framework/.claude/skills/kie-ai/scripts/setup_api_key.sh +77 -0
- package/framework/.claude/skills/motion-design/LICENSE +21 -0
- package/framework/.claude/skills/motion-design/README.md +82 -0
- package/framework/.claude/skills/motion-design/SKILL.md +336 -0
- package/framework/.claude/skills/motion-design/director/choreography.md +93 -0
- package/framework/.claude/skills/motion-design/director/context-adaptation.md +83 -0
- package/framework/.claude/skills/motion-design/director/core-philosophy.md +53 -0
- package/framework/.claude/skills/motion-design/director/decision-framework.md +91 -0
- package/framework/.claude/skills/motion-design/director/disney-principles.md +102 -0
- package/framework/.claude/skills/motion-design/director/emotion-mapping.md +71 -0
- package/framework/.claude/skills/motion-design/director/motion-personality.md +89 -0
- package/framework/.claude/skills/motion-design/director/narrative-structure.md +62 -0
- package/framework/.claude/skills/motion-design/patterns/ambient-continuous.md +81 -0
- package/framework/.claude/skills/motion-design/patterns/entrance-exit.md +82 -0
- package/framework/.claude/skills/motion-design/patterns/multi-element.md +69 -0
- package/framework/.claude/skills/motion-design/patterns/state-feedback.md +96 -0
- package/framework/.claude/skills/motion-design/reference/property-selection.md +95 -0
- package/framework/.claude/skills/motion-design/reference/quality-checklist.md +67 -0
- package/framework/.claude/skills/motion-design/reference/timing-easing-tables.md +106 -0
- package/framework/.claude/skills/motion-design/reference/troubleshooting.md +73 -0
- package/framework/.claude/skills/new/SKILL.md +1687 -0
- package/framework/.claude/skills/playwright-skill/API_REFERENCE.md +652 -0
- package/framework/.claude/skills/playwright-skill/SKILL.md +157 -0
- package/framework/.claude/skills/playwright-skill/package.json +26 -0
- package/framework/.claude/skills/prd/SKILL.md +228 -0
- package/framework/.claude/skills/prd/assets/card-template.yml +232 -0
- package/framework/.claude/skills/prd/assets/epic-template.yml +190 -0
- package/framework/.claude/skills/prd/assets/prd-template.md +230 -0
- package/framework/.claude/skills/prd/assets/state-template.md +78 -0
- package/framework/.claude/skills/prd/references/api-perf-gate.md +152 -0
- package/framework/.claude/skills/prd/references/audit-phase.md +478 -0
- package/framework/.claude/skills/prd/references/backlog-phase.md +145 -0
- package/framework/.claude/skills/prd/references/discovery-phase.md +359 -0
- package/framework/.claude/skills/prd/references/impact-analysis.md +233 -0
- package/framework/.claude/skills/prd/references/prd-add-phase.md +214 -0
- package/framework/.claude/skills/prd/references/prd-writing-phase.md +145 -0
- package/framework/.claude/skills/prd/references/research-phase.md +216 -0
- package/framework/.claude/skills/prd/references/ui-design-phase.md +61 -0
- package/framework/.claude/skills/prd/references/validation-phase.md +72 -0
- package/framework/.claude/skills/prd-add/SKILL.md +222 -0
- package/framework/.claude/skills/prd-add/references/impact-analysis.md +233 -0
- package/framework/.claude/skills/remotion-best-practices/SKILL.md +48 -0
- package/framework/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
- package/framework/.claude/skills/remotion-best-practices/rules/animations.md +29 -0
- package/framework/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
- package/framework/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/framework/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/framework/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
- package/framework/.claude/skills/remotion-best-practices/rules/audio.md +169 -0
- package/framework/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
- package/framework/.claude/skills/remotion-best-practices/rules/can-decode.md +75 -0
- package/framework/.claude/skills/remotion-best-practices/rules/charts.md +58 -0
- package/framework/.claude/skills/remotion-best-practices/rules/compositions.md +141 -0
- package/framework/.claude/skills/remotion-best-practices/rules/display-captions.md +184 -0
- package/framework/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/framework/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/framework/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/framework/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/framework/.claude/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
- package/framework/.claude/skills/remotion-best-practices/rules/gifs.md +141 -0
- package/framework/.claude/skills/remotion-best-practices/rules/images.md +130 -0
- package/framework/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
- package/framework/.claude/skills/remotion-best-practices/rules/light-leaks.md +73 -0
- package/framework/.claude/skills/remotion-best-practices/rules/lottie.md +67 -0
- package/framework/.claude/skills/remotion-best-practices/rules/maps.md +401 -0
- package/framework/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
- package/framework/.claude/skills/remotion-best-practices/rules/measuring-text.md +143 -0
- package/framework/.claude/skills/remotion-best-practices/rules/parameters.md +98 -0
- package/framework/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/framework/.claude/skills/remotion-best-practices/rules/subtitles.md +36 -0
- package/framework/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/framework/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/framework/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
- package/framework/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
- package/framework/.claude/skills/remotion-best-practices/rules/transitions.md +197 -0
- package/framework/.claude/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
- package/framework/.claude/skills/remotion-best-practices/rules/trimming.md +52 -0
- package/framework/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
- package/framework/.claude/skills/seo-audit/SKILL.md +394 -0
- package/framework/.claude/skills/seo-audit/references/aeo-geo-patterns.md +279 -0
- package/framework/.claude/skills/seo-audit/references/ai-writing-detection.md +190 -0
- package/framework/.claude/skills/simplify/SKILL.md +137 -0
- package/framework/.claude/skills/skill-creator/LICENSE.txt +202 -0
- package/framework/.claude/skills/skill-creator/SKILL.md +356 -0
- package/framework/.claude/skills/skill-creator/references/output-patterns.md +82 -0
- package/framework/.claude/skills/skill-creator/references/workflows.md +28 -0
- package/framework/.claude/skills/skill-creator/scripts/init_skill.py +303 -0
- package/framework/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
- package/framework/.claude/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/framework/.claude/skills/ui-design/SKILL.md +199 -0
- package/framework/.claude/skills/ui-design/references/component-discovery.md +54 -0
- package/framework/.claude/skills/ui-design/references/evaluation.md +171 -0
- package/framework/.claude/skills/ui-design/references/generation.md +109 -0
- package/framework/.claude/skills/ui-design/references/inventory.md +59 -0
- package/framework/.claude/skills/webapp-testing/LICENSE.txt +202 -0
- package/framework/.claude/skills/webapp-testing/SKILL.md +123 -0
- package/framework/.claude/skills/webapp-testing/examples/console_logging.py +35 -0
- package/framework/.claude/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/framework/.claude/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/framework/.claude/skills/webapp-testing/scripts/with_server.py +106 -0
- package/framework/.claude/skills/worktree-manager/SKILL.md +680 -0
- package/framework/AGENTS.md +240 -0
- package/framework/agents/api-contracts.md +137 -0
- package/framework/agents/architecture.md +145 -0
- package/framework/agents/coding-standards.md +148 -0
- package/framework/agents/data-model.md +110 -0
- package/framework/agents/deployment-protocol.md +232 -0
- package/framework/agents/design-review.md +172 -0
- package/framework/agents/env-reference.md +171 -0
- package/framework/agents/github-issue-subagent.md +252 -0
- package/framework/agents/index.md +261 -0
- package/framework/agents/llm-wiki-methodology.md +216 -0
- package/framework/agents/maintenance-protocol.md +305 -0
- package/framework/agents/observability.md +162 -0
- package/framework/agents/performance.md +155 -0
- package/framework/agents/project-context.md +145 -0
- package/framework/agents/runbook.md +208 -0
- package/framework/agents/security.md +168 -0
- package/framework/agents/skills-mapping.md +286 -0
- package/framework/agents/testing.md +111 -0
- package/framework/agents/workflows.md +215 -0
- package/framework/docs/PROJECT-CONFIGURATION.md +336 -0
- package/framework/docs/references/brand-guidelines.md +170 -0
- package/framework/docs/references/ui-guidelines.template.md +182 -0
- package/framework/routines/code-review.routine.yml +46 -0
- package/framework/routines/doc-review.routine.yml +45 -0
- package/framework/routines/ds-drift.routine.yml +52 -0
- package/framework/routines/full-sweep.routine.yml +51 -0
- package/framework/routines/index.yml +70 -0
- package/framework/routines/skill-improve.routine.yml +50 -0
- package/framework/routines/wiki-review.routine.yml +45 -0
- package/framework/templates/baldart.config.template.yml +113 -0
- package/framework/templates/breaking-change-checklist.md +484 -0
- package/framework/templates/feature-card.template.yml +125 -0
- package/framework/templates/overlays/README.md +44 -0
- package/framework/templates/overlays/copywriting.fidelity-example.md +62 -0
- package/framework/templates/overlays/ui-design.fidelity-example.md +75 -0
- package/framework/templates/skill-project-context.snippet.md +19 -0
- package/framework/templates/spec.template.md +208 -0
- package/package.json +51 -0
- package/src/commands/add.js +229 -0
- package/src/commands/configure.js +385 -0
- package/src/commands/doctor.js +486 -0
- package/src/commands/migrate.js +185 -0
- package/src/commands/push.js +0 -0
- package/src/commands/routines.js +269 -0
- package/src/commands/status.js +130 -0
- package/src/commands/update.js +419 -0
- package/src/commands/version.js +88 -0
- package/src/utils/contamination.js +400 -0
- package/src/utils/git.js +181 -0
- package/src/utils/hooks.js +152 -0
- package/src/utils/routine-adapters/claude-code-cloud.js +78 -0
- package/src/utils/routine-adapters/cron.js +138 -0
- package/src/utils/routine-adapters/github-actions.js +141 -0
- package/src/utils/routine-adapters/index.js +21 -0
- package/src/utils/routines.js +166 -0
- package/src/utils/state.js +143 -0
- package/src/utils/symlinks.js +425 -0
- package/src/utils/ui.js +133 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Production-ready REST API template using FastAPI.
|
|
3
|
+
Includes pagination, filtering, error handling, and best practices.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from fastapi import FastAPI, HTTPException, Query, Path, Depends, status
|
|
7
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
8
|
+
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
|
9
|
+
from fastapi.responses import JSONResponse
|
|
10
|
+
from pydantic import BaseModel, Field, EmailStr, ConfigDict
|
|
11
|
+
from typing import Optional, List, Any
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from enum import Enum
|
|
14
|
+
|
|
15
|
+
app = FastAPI(
|
|
16
|
+
title="API Template",
|
|
17
|
+
version="1.0.0",
|
|
18
|
+
docs_url="/api/docs"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Security Middleware
|
|
22
|
+
# Trusted Host: Prevents HTTP Host Header attacks
|
|
23
|
+
app.add_middleware(
|
|
24
|
+
TrustedHostMiddleware,
|
|
25
|
+
allowed_hosts=["*"] # TODO: Configure this in production, e.g. ["api.example.com"]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# CORS: Configures Cross-Origin Resource Sharing
|
|
29
|
+
app.add_middleware(
|
|
30
|
+
CORSMiddleware,
|
|
31
|
+
allow_origins=["*"], # TODO: Update this with specific origins in production
|
|
32
|
+
allow_credentials=False, # TODO: Set to True if you need cookies/auth headers, but restrict origins
|
|
33
|
+
allow_methods=["*"],
|
|
34
|
+
allow_headers=["*"],
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Models
|
|
38
|
+
class UserStatus(str, Enum):
|
|
39
|
+
ACTIVE = "active"
|
|
40
|
+
INACTIVE = "inactive"
|
|
41
|
+
SUSPENDED = "suspended"
|
|
42
|
+
|
|
43
|
+
class UserBase(BaseModel):
|
|
44
|
+
email: EmailStr
|
|
45
|
+
name: str = Field(..., min_length=1, max_length=100)
|
|
46
|
+
status: UserStatus = UserStatus.ACTIVE
|
|
47
|
+
|
|
48
|
+
class UserCreate(UserBase):
|
|
49
|
+
password: str = Field(..., min_length=8)
|
|
50
|
+
|
|
51
|
+
class UserUpdate(BaseModel):
|
|
52
|
+
email: Optional[EmailStr] = None
|
|
53
|
+
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
54
|
+
status: Optional[UserStatus] = None
|
|
55
|
+
|
|
56
|
+
class User(UserBase):
|
|
57
|
+
id: str
|
|
58
|
+
created_at: datetime
|
|
59
|
+
updated_at: datetime
|
|
60
|
+
|
|
61
|
+
model_config = ConfigDict(from_attributes=True)
|
|
62
|
+
|
|
63
|
+
# Pagination
|
|
64
|
+
class PaginationParams(BaseModel):
|
|
65
|
+
page: int = Field(1, ge=1)
|
|
66
|
+
page_size: int = Field(20, ge=1, le=100)
|
|
67
|
+
|
|
68
|
+
class PaginatedResponse(BaseModel):
|
|
69
|
+
items: List[Any]
|
|
70
|
+
total: int
|
|
71
|
+
page: int
|
|
72
|
+
page_size: int
|
|
73
|
+
pages: int
|
|
74
|
+
|
|
75
|
+
# Error handling
|
|
76
|
+
class ErrorDetail(BaseModel):
|
|
77
|
+
field: Optional[str] = None
|
|
78
|
+
message: str
|
|
79
|
+
code: str
|
|
80
|
+
|
|
81
|
+
class ErrorResponse(BaseModel):
|
|
82
|
+
error: str
|
|
83
|
+
message: str
|
|
84
|
+
details: Optional[List[ErrorDetail]] = None
|
|
85
|
+
|
|
86
|
+
@app.exception_handler(HTTPException)
|
|
87
|
+
async def http_exception_handler(request, exc):
|
|
88
|
+
return JSONResponse(
|
|
89
|
+
status_code=exc.status_code,
|
|
90
|
+
content=ErrorResponse(
|
|
91
|
+
error=exc.__class__.__name__,
|
|
92
|
+
message=exc.detail if isinstance(exc.detail, str) else exc.detail.get("message", "Error"),
|
|
93
|
+
details=exc.detail.get("details") if isinstance(exc.detail, dict) else None
|
|
94
|
+
).model_dump()
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Endpoints
|
|
98
|
+
@app.get("/api/users", response_model=PaginatedResponse, tags=["Users"])
|
|
99
|
+
async def list_users(
|
|
100
|
+
page: int = Query(1, ge=1),
|
|
101
|
+
page_size: int = Query(20, ge=1, le=100),
|
|
102
|
+
status: Optional[UserStatus] = Query(None),
|
|
103
|
+
search: Optional[str] = Query(None)
|
|
104
|
+
):
|
|
105
|
+
"""List users with pagination and filtering."""
|
|
106
|
+
# Mock implementation
|
|
107
|
+
total = 100
|
|
108
|
+
items = [
|
|
109
|
+
User(
|
|
110
|
+
id=str(i),
|
|
111
|
+
email=f"user{i}@example.com",
|
|
112
|
+
name=f"User {i}",
|
|
113
|
+
status=UserStatus.ACTIVE,
|
|
114
|
+
created_at=datetime.now(),
|
|
115
|
+
updated_at=datetime.now()
|
|
116
|
+
).model_dump()
|
|
117
|
+
for i in range((page-1)*page_size, min(page*page_size, total))
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
return PaginatedResponse(
|
|
121
|
+
items=items,
|
|
122
|
+
total=total,
|
|
123
|
+
page=page,
|
|
124
|
+
page_size=page_size,
|
|
125
|
+
pages=(total + page_size - 1) // page_size
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@app.post("/api/users", response_model=User, status_code=status.HTTP_201_CREATED, tags=["Users"])
|
|
129
|
+
async def create_user(user: UserCreate):
|
|
130
|
+
"""Create a new user."""
|
|
131
|
+
# Mock implementation
|
|
132
|
+
return User(
|
|
133
|
+
id="123",
|
|
134
|
+
email=user.email,
|
|
135
|
+
name=user.name,
|
|
136
|
+
status=user.status,
|
|
137
|
+
created_at=datetime.now(),
|
|
138
|
+
updated_at=datetime.now()
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
@app.get("/api/users/{user_id}", response_model=User, tags=["Users"])
|
|
142
|
+
async def get_user(user_id: str = Path(..., description="User ID")):
|
|
143
|
+
"""Get user by ID."""
|
|
144
|
+
# Mock: Check if exists
|
|
145
|
+
if user_id == "999":
|
|
146
|
+
raise HTTPException(
|
|
147
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
|
148
|
+
detail={"message": "User not found", "details": {"id": user_id}}
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
return User(
|
|
152
|
+
id=user_id,
|
|
153
|
+
email="user@example.com",
|
|
154
|
+
name="User Name",
|
|
155
|
+
status=UserStatus.ACTIVE,
|
|
156
|
+
created_at=datetime.now(),
|
|
157
|
+
updated_at=datetime.now()
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
@app.patch("/api/users/{user_id}", response_model=User, tags=["Users"])
|
|
161
|
+
async def update_user(user_id: str, update: UserUpdate):
|
|
162
|
+
"""Partially update user."""
|
|
163
|
+
# Validate user exists
|
|
164
|
+
existing = await get_user(user_id)
|
|
165
|
+
|
|
166
|
+
# Apply updates
|
|
167
|
+
update_data = update.model_dump(exclude_unset=True)
|
|
168
|
+
for field, value in update_data.items():
|
|
169
|
+
setattr(existing, field, value)
|
|
170
|
+
|
|
171
|
+
existing.updated_at = datetime.now()
|
|
172
|
+
return existing
|
|
173
|
+
|
|
174
|
+
@app.delete("/api/users/{user_id}", status_code=status.HTTP_204_NO_CONTENT, tags=["Users"])
|
|
175
|
+
async def delete_user(user_id: str):
|
|
176
|
+
"""Delete user."""
|
|
177
|
+
await get_user(user_id) # Verify exists
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
if __name__ == "__main__":
|
|
181
|
+
import uvicorn
|
|
182
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|