diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc deleted file mode 100644 index 9a9eed1..0000000 Binary files a/__pycache__/main.cpython-39.pyc and /dev/null differ diff --git a/main.py b/main.py index 2b5918f..bda4d8e 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,10 @@ from fastapi import FastAPI +from src.application.routers import users -from src.domain.user.user_entity import User, UserDTO app = FastAPI() +app.include_router(users.router) - -@app.post("/") -async def users(user_props: UserDTO): - user = User(user_props) - return {"user": user} +@app.get("/") +async def home(): + return {"status": "ok"} diff --git a/setup.md b/setup.md index 22c8fd4..5d0df85 100644 --- a/setup.md +++ b/setup.md @@ -36,5 +36,6 @@ colocar as depedencias da dependecia no requirements pip install -r requirements.txt +uvicorn main:app --reload diff --git a/src/__pycache__/__init__.cpython-39.pyc b/src/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 4be7465..0000000 Binary files a/src/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/src/application/routers/__init__.py b/src/application/routers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/application/routers/users.py b/src/application/routers/users.py new file mode 100644 index 0000000..b7611bb --- /dev/null +++ b/src/application/routers/users.py @@ -0,0 +1,19 @@ +from fastapi import APIRouter, HTTPException +from src.domain.user.user_entity import User, UserDTO + + +router = APIRouter( + prefix="/users", + tags=["users"], + # TODO dependencies=[Depends(get_token_header)], + responses={404: {"description": "Não encontrado"}}, +) + +@router.post("/", description="Api to save user", status_code=201) +async def save_user(user_props: UserDTO): + user = User(user_props) + return {"user": user} + +@router.get("/", description="Api to list users") +async def users(): + return [User(user_props=UserDTO(age=0))] diff --git a/src/domain/__pycache__/__init__.cpython-39.pyc b/src/domain/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index 31432c5..0000000 Binary files a/src/domain/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/src/domain/user/__pycache__/__init__.cpython-39.pyc b/src/domain/user/__pycache__/__init__.cpython-39.pyc index bb180c0..fd985a2 100644 Binary files a/src/domain/user/__pycache__/__init__.cpython-39.pyc and b/src/domain/user/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/domain/user/__pycache__/user_entity.cpython-39.pyc b/src/domain/user/__pycache__/user_entity.cpython-39.pyc index e151c3d..ca4d04a 100644 Binary files a/src/domain/user/__pycache__/user_entity.cpython-39.pyc and b/src/domain/user/__pycache__/user_entity.cpython-39.pyc differ