diff --git a/linguaphoto/routers/users.py b/linguaphoto/routers/users.py index 6e97fa3..55958cb 100644 --- a/linguaphoto/routers/users.py +++ b/linguaphoto/routers/users.py @@ -102,10 +102,7 @@ async def get_login_response(email: str, lifetime: int, crud: Crud) -> UserLogin async def get_google_user_info(token: str) -> dict: async with aiohttp.ClientSession() as session: - response = await session.get( - "https://www.googleapis.com/oauth2/v3/userinfo", - params={"access_token": token}, - ) + response = await session.get("https://www.googleapis.com/oauth2/v3/userinfo", params={"access_token": token}) if response.status != 200: raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid Google token") return await response.json() diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..f455f20 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,3 @@ +# .gitignore + +*.log diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml new file mode 100644 index 0000000..017ff31 --- /dev/null +++ b/scripts/docker-compose.yml @@ -0,0 +1,15 @@ +# Composes DynamoDB Local, the DynamoDB Admin UI, and Redis +version: '3.7' + +services: + dynamodb: + image: amazon/dynamodb-local + ports: + - "8000:8000" + + dynamodb-admin: + image: aaronshaf/dynamodb-admin + ports: + - "8001:8001" + environment: + - DYNAMO_ENDPOINT=http://dynamodb:8000 diff --git a/scripts/start_all.sh b/scripts/start_all.sh new file mode 100755 index 0000000..6067a0d --- /dev/null +++ b/scripts/start_all.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Starts the databases, frontend and backend. + +set -e + +cur_dir=$(realpath $(dirname $0)) +root_dir=$(realpath $(dirname $cur_dir)) + +docker_log=${cur_dir}/docker.log +backend_log=${cur_dir}/backend.log +frontend_log=${cur_dir}/frontend.log + +# Define cleanup function +cleanup() { + echo "Stopping databases..." + docker-compose -f ${cur_dir}/docker-compose.yml down + echo "Killing FastAPI..." + kill $backend_pid || true + echo "Killing React..." + kill $frontend_pid || true + echo "Waiting for services to stop..." + wait $docker_compose_pid + wait $backend_pid + wait $frontend_pid + echo "Services stopped." +} + +# Set trap for cleanup on exit +trap cleanup EXIT + +# Starts docker and gets the pid +docker-compose -f ${cur_dir}/docker-compose.yml up > $docker_log 2>&1 & +docker_compose_pid=$! + +# Starts FastAPI and gets the pid +fastapi dev ${root_dir}/linguaphoto/main.py --port 8080 > $backend_log 2>&1 & +backend_pid=$! + +# Starts React and gets the pid +cd ${root_dir}/frontend +npm start > $frontend_log 2>&1 & +frontend_pid=$! + +# Wait for user to press enter +echo "=====================================" +echo "Docker, FastAPI and React are running" +echo " Visit http://localhost:3000 " +echo "=====================================" + +read -p "Press enter to stop the services" + +# Exits +exit 0