diff --git a/backend/app/.mypy.ini b/backend/app/.mypy.ini new file mode 100644 index 0000000..2a7fdbb --- /dev/null +++ b/backend/app/.mypy.ini @@ -0,0 +1,4 @@ +[mypy] +files = app/ +plugins = sqlmypy +ignore_missing_imports = True \ No newline at end of file diff --git a/backend/app/__init__.py b/backend/app/__init__.py index 61ef994..7f84074 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -1,29 +1,29 @@ -from flask import Flask -from flask_jwt_extended import JWTManager -from flask_mail import Mail -from flasgger import Swagger +# from flask import Flask +# from flask_jwt_extended import JWTManager +# from flask_mail import Mail +# from flasgger import Swagger -from app.doc.main_swag import main_swagger +# from app.doc.main_swag import main_swagger -app = Flask(__name__) -from app.config import FlaskTesting, FlaskProduction +# app = Flask(__name__) +# from app.config import FlaskTesting, FlaskProduction -app.config.from_object(FlaskTesting) +# app.config.from_object(FlaskTesting) -flask_mail = Mail(app) -jwt_manager = JWTManager(app) -swag = Swagger(app, template=main_swagger) +# flask_mail = Mail(app) +# jwt_manager = JWTManager(app) +# swag = Swagger(app, template=main_swagger) -def create_app(): - from app.api import bp, bp_errors, bp_product, bp_user, bp_cart +# def create_app(): +# from app.api import bp, bp_errors, bp_product, bp_user, bp_cart - app.register_blueprint(bp) - app.register_blueprint(bp_errors) - app.register_blueprint(bp_product) - app.register_blueprint(bp_user) - app.register_blueprint(bp_cart) +# app.register_blueprint(bp) +# app.register_blueprint(bp_errors) +# app.register_blueprint(bp_product) +# app.register_blueprint(bp_user) +# app.register_blueprint(bp_cart) - from . import jwt_utils +# from . import jwt_utils - return app +# return app diff --git a/backend/app/main.py b/backend/app/main.py index 8e3dfea..4088510 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1,7 +1,17 @@ from fastapi import FastAPI +from .routes.cart_routes import router as cart_router +from .routes.user_routes import router as user_router + + +app = FastAPI( + title="SWAG Shop", + version="0.0.1" +) + +app.include_router(user_router) +app.include_router(cart_router) -app = FastAPI() @app.get("/") async def root(): - return {"message": "Hello World"} \ No newline at end of file + return {"message": "Hello World"} diff --git a/backend/app/routes/__init__.py b/backend/app/routes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/app/routes/cart_routes.py b/backend/app/routes/cart_routes.py new file mode 100644 index 0000000..73bb352 --- /dev/null +++ b/backend/app/routes/cart_routes.py @@ -0,0 +1,38 @@ +from fastapi import APIRouter, Query + +router = APIRouter( + prefix="/cart", + tags=["Cart"] +) + + +@router.get("/") +async def show_cart(): + raise NotImplementedError + + +@router.put("/add/{product_id}") +async def add_to_cart( + product_id: int, + count: int = Query( + 1, ge=1, description="Count must be greater than or equal to 1") +): + raise NotImplementedError + + +@router.delete("/remove/{product_id}") +async def remove_from_cart(product_id: int): + raise NotImplementedError + + +@router.put("/update/{product_id}") +async def update_count_in_cart( + product_id: int, + count: int = Query(..., description="Count must be provided") +): + raise NotImplementedError + + +@router.get("/purchase") +async def purchase(): + raise NotImplementedError diff --git a/backend/app/routes/shop_routes.py b/backend/app/routes/shop_routes.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/app/routes/user_routes.py b/backend/app/routes/user_routes.py new file mode 100644 index 0000000..b84989f --- /dev/null +++ b/backend/app/routes/user_routes.py @@ -0,0 +1,31 @@ +from fastapi import APIRouter, Body + +router = APIRouter( + prefix="/user", + tags=["User"] +) + + +@router.delete("/delete", summary="Delete user") +async def delete_user(): + raise NotImplementedError("delete_user() needs to be implemented.") + + +@router.post("/login", summary="User login") +async def login(data: dict = Body(...)): + raise NotImplementedError("login() needs to be implemented.") + + +@router.delete("/logout", summary="User logout") +async def logout(): + raise NotImplementedError("logout() needs to be implemented.") + + +@router.post("/register", summary="Register new user") +async def register(data: dict = Body(...)): + raise NotImplementedError("register() needs to be implemented.") + + +@router.put("/update", summary="Update user details") +async def update_user(data: dict = Body(...)): + raise NotImplementedError("update_user() needs to be implemented.")