Skip to content

Commit

Permalink
Merge pull request #148 from grillazz/94-add-test-coverage
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
grillazz committed May 8, 2024
2 parents db933fa + 918ab6c commit 1c33124
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 189 deletions.
2 changes: 1 addition & 1 deletion app/api/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@router.get("/redis", status_code=status.HTTP_200_OK)
async def redis_check(request: Request):
_redis = await request.app.state.redis
_redis = await request.app.redis
_info = None
try:
_info = await _redis.info()
Expand Down
6 changes: 3 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


@asynccontextmanager
async def lifespan(app: FastAPI):
async def lifespan(_app: FastAPI):
# Load the redis connection
app.state.redis = await get_redis()
_app.redis = await get_redis()

try:
# Initialize the cache with the redis connection
Expand All @@ -29,7 +29,7 @@ async def lifespan(app: FastAPI):
yield
finally:
# close redis connection and release the resources
await app.state.redis.close()
await _app.redis.close()


app = FastAPI(title="Stuff And Nonsense API", version="0.6", lifespan=lifespan)
Expand Down
4 changes: 2 additions & 2 deletions app/services/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@


async def get_from_redis(request: Request, key: str):
return await request.app.state.redis.get(key)
return await request.app.redis.get(key)


async def set_to_redis(request: Request, key: str, value: str, ex: int):
return await request.app.state.redis.set(key, value, ex=ex)
return await request.app.redis.set(key, value, ex=ex)


async def verify_jwt(request: Request, token: str) -> bool:
Expand Down
Loading

0 comments on commit 1c33124

Please sign in to comment.