Skip to content

Commit

Permalink
Add users router
Browse files Browse the repository at this point in the history
  • Loading branch information
leonildoalbani-mb committed Jul 20, 2022
1 parent d4b745a commit 5c07a3a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
Binary file removed __pycache__/main.cpython-39.pyc
Binary file not shown.
11 changes: 5 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -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"}
1 change: 1 addition & 0 deletions setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ colocar as depedencias da dependecia no requirements

pip install -r requirements.txt

uvicorn main:app --reload


Binary file removed src/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Empty file.
19 changes: 19 additions & 0 deletions src/application/routers/users.py
Original file line number Diff line number Diff line change
@@ -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))]
Binary file removed src/domain/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified src/domain/user/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified src/domain/user/__pycache__/user_entity.cpython-39.pyc
Binary file not shown.

0 comments on commit 5c07a3a

Please sign in to comment.