diff --git a/docker-compose.yml b/docker-compose.yml index 212380c..fd4d78b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,40 +1,38 @@ -version: '3.7' - services: - gateway: - image: baranbartu/k-api-gateway:latest - command: sh -c "uvicorn main:app --reload --host 0.0.0.0" - build: - context: ./gateway - dockerfile: Dockerfile - env_file: - - ./gateway/.env - ports: - - 8001:8000 - depends_on: - - users - - orders - volumes: - - ./gateway:/app + gateway: + image: baranbartu/k-api-gateway:latest + command: sh -c "uvicorn main:app --reload --host 0.0.0.0" + build: + context: ./gateway + dockerfile: Dockerfile + env_file: + - ./gateway/.env + ports: + - 8001:8000 + depends_on: + - users + - orders + volumes: + - ./gateway:/app - users: - image: baranbartu/k-users:latest - command: sh -c "uvicorn main:app --reload --host 0.0.0.0" - build: - context: ./users - dockerfile: Dockerfile - env_file: - - ./users/.env - volumes: - - ./users:/app + users: + image: baranbartu/k-users:latest + command: sh -c "uvicorn main:app --reload --host 0.0.0.0" + build: + context: ./users + dockerfile: Dockerfile + env_file: + - ./users/.env + volumes: + - ./users:/app - orders: - image: baranbartu/k-orders:latest - command: sh -c "uvicorn main:app --reload --host 0.0.0.0" - build: - context: ./orders - dockerfile: Dockerfile - env_file: - - ./orders/.env - volumes: - - ./orders:/app + orders: + image: baranbartu/k-orders:latest + command: sh -c "uvicorn main:app --reload --host 0.0.0.0" + build: + context: ./orders + dockerfile: Dockerfile + env_file: + - ./orders/.env + volumes: + - ./orders:/app diff --git a/gateway/Dockerfile b/gateway/Dockerfile index 8997a72..8fe212c 100644 --- a/gateway/Dockerfile +++ b/gateway/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7.7 +FROM python:3.11 WORKDIR /app @@ -8,4 +8,4 @@ ENV PYTHONBUFFERED 1 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY . . \ No newline at end of file diff --git a/gateway/auth.py b/gateway/auth.py index 378d166..e0845b5 100644 --- a/gateway/auth.py +++ b/gateway/auth.py @@ -1,6 +1,6 @@ import jwt -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from conf import settings from exceptions import AuthTokenMissing, AuthTokenExpired, AuthTokenCorrupted @@ -17,7 +17,8 @@ def generate_access_token( ) ): - expire = datetime.utcnow() + expires_delta + expire = datetime.now(timezone.utc) + expires_delta + token_data = { 'id': data['id'], 'user_type': data['user_type'], diff --git a/gateway/conf.py b/gateway/conf.py index f466680..73e5159 100644 --- a/gateway/conf.py +++ b/gateway/conf.py @@ -1,6 +1,7 @@ import os -from pydantic import BaseSettings +from pydantic_settings import BaseSettings + class Settings(BaseSettings): diff --git a/gateway/requirements.txt b/gateway/requirements.txt index b3adc95..d42fe36 100644 --- a/gateway/requirements.txt +++ b/gateway/requirements.txt @@ -1,12 +1,15 @@ -fastapi==0.58.0 -uvicorn==0.11.5 -PyJWT==1.7.1 +fastapi==0.112.1 +uvicorn==0.30.6 +PyJWT==2.9.0 +pydantic-settings==2.4.0 + +async_timeout==4.0.3 # async http requests & fast dns resolving -aiohttp==3.6.2 -aiodns==2.0.0 +aiohttp==3.10.5 +aiodns==3.2.0 # for test purposes -flake8==3.8.3 -ipdb==0.13.2 -ipython==7.15.0 +flake8==7.1.1 +ipdb==0.13.13 +ipython==8.26.0 diff --git a/orders/Dockerfile b/orders/Dockerfile index 8997a72..f9a25bb 100644 --- a/orders/Dockerfile +++ b/orders/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7.7 +FROM python:3.11 WORKDIR /app diff --git a/orders/main.py b/orders/main.py index 1a3e0a3..fb6ed15 100644 --- a/orders/main.py +++ b/orders/main.py @@ -19,7 +19,7 @@ async def get_orders(request_user_id: str = Header(None)): @app.post('/api/orders', response_model=Order_Pydantic) async def create_user(order: OrderIn_Pydantic, request_user_id: str = Header(None)): - data = order.dict() + data = order.model_dump() data.update({'created_by': request_user_id}) order_obj = await Orders.create(**data) diff --git a/orders/requirements.txt b/orders/requirements.txt index 7034721..2c44391 100644 --- a/orders/requirements.txt +++ b/orders/requirements.txt @@ -1,8 +1,8 @@ -fastapi==0.58.0 -uvicorn==0.11.5 -tortoise-orm==0.16.13 +fastapi==0.112.1 +uvicorn==0.30.6 +tortoise-orm==0.21.6 # for test purposes -flake8==3.8.3 -ipdb==0.13.2 -ipython==7.15.0 +flake8==7.1.1 +ipdb==0.13.13 +ipython==8.26.0 \ No newline at end of file diff --git a/users/Dockerfile b/users/Dockerfile index 8997a72..f9a25bb 100644 --- a/users/Dockerfile +++ b/users/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7.7 +FROM python:3.11 WORKDIR /app diff --git a/users/main.py b/users/main.py index b63718a..063ccf0 100644 --- a/users/main.py +++ b/users/main.py @@ -55,7 +55,7 @@ async def create_user(user: UserForm, ) hashed_password = get_password_hash(user.password) - data = user.dict() + data = user.model_dump() user_in_db = insert_user(data, hashed_password, request_user_id) return user_in_db diff --git a/users/requirements.txt b/users/requirements.txt index 29f0f6c..69dc668 100644 --- a/users/requirements.txt +++ b/users/requirements.txt @@ -1,9 +1,9 @@ -fastapi==0.58.0 -uvicorn==0.11.5 -passlib==1.7.2 -bcrypt==3.1.7 +fastapi==0.112.1 +uvicorn==0.30.6 +passlib==1.7.4 +bcrypt==4.2.0 # for test purposes -flake8==3.8.3 -ipdb==0.13.2 -ipython==7.15.0 +flake8==7.1.1 +ipdb==0.13.13 +ipython==8.26.0