feat: Update endpoint project

This commit is contained in:
Backend IM Bot 2025-03-11 09:31:15 +00:00
parent a91422cf81
commit a62582fbfb

View File

@ -0,0 +1,29 @@
from typing import Optional
from fastapi import APIRouter, Depends
from pydantic import BaseModel
router = APIRouter()
class ProjectBase(BaseModel):
name: str
description: Optional[str] = None
class ProjectCreate(ProjectBase):
pass
class Project(ProjectBase):
id: int
class Config:
orm_mode = True
@router.post("/project", response_model=Project)
async def create_project(project: ProjectCreate, db=Depends(get_db)):
"""
Create a new project
"""
db_project = Project(**project.dict())
db.add(db_project)
db.commit()
db.refresh(db_project)
return db_project