Skip to content

Commit

Permalink
Save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Nov 14, 2024
1 parent 8814d8b commit 0a9a523
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 14 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pydantic import BaseModel


class BasicResponse(BaseModel):
message: str
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
from typing import Union

from .common.app import app
from .module.auth import route as auth_route
from .module.gateway import route as gateway_route

assert gateway_route
assert auth_route


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
from ...common.app import app
from ...common.schema import BasicResponse
from ...config import APP_MODE, APP_MODULES
from .usecase import usecase
from .user.usecase import user_usecase

if APP_MODE == "microservices" and "library" in APP_MODULES:
if APP_MODE == "microservices" and "auth" in APP_MODULES:

@app.get("/library/greeting")
@app.api_route("/health", methods=["GET", "HEAD"], response_class=BasicResponse)
async def health():
return BasicResponse(message="ok")

@app.api_route("/readiness", methods=["GET", "HEAD"], response_class=BasicResponse)
async def readiness():
return BasicResponse(message="ok")

@app.get("/user/greeting")
def greet(name: str) -> str:
return usecase.greet(name)
return user_usecase.greet(name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ....schema.user import NewUserData, User, UserData


class Usecase:
def get_user_by_id(id: str) -> UserData:
pass

def get_user() -> list[UserData]:
pass

def insert_user(data: NewUserData) -> User:
pass

def insert_users(data: list[NewUserData]) -> list[User]:
pass

def update_user(id: str, data: NewUserData) -> User:
pass


user_usecase = Usecase()
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from fastapi.responses import PlainTextResponse

from ...common.app import app
from ...common.schema import BasicResponse
from ...config import APP_MODE, APP_MODULES
from ..auth.client.factory import client
from ..auth.client.factory import client as auth_client

if APP_MODE == "monolith" or "gateway" in APP_MODULES:

@app.api_route("/health", methods=["GET", "HEAD"], response_class=BasicResponse)
async def health():
return BasicResponse(message="ok")

@app.api_route("/readiness", methods=["GET", "HEAD"], response_class=BasicResponse)
async def readiness():
return BasicResponse(message="ok")

@app.get("/", response_class=PlainTextResponse)
async def read_root():
return await client.greet("world")
return await auth_client.greet("world")
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pydantic import BaseModel


class UserData(BaseModel):
username: str


class NewUserData(UserData):
password: str


class User(UserData):
id: str

0 comments on commit 0a9a523

Please sign in to comment.