-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project routes and Github Route (#13)
* added project routes, added docker container in docker compose,updated envtemplate and added fix for ssl error for mongo in development * added project routes * removed redundant code * Delete firebase_service_account.json:Zone.Identifier * added github routes * separated code from router and added controller methods * updated env template * updated Project and Github Controller * added back connection pooling
- Loading branch information
Showing
12 changed files
with
254 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
ENV= development | ||
OPENAI_API_KEY= | ||
OPENAI_MODEL_REASONING= | ||
OPENAI_MODEL_REASONING= | ||
# POSTGRES_SERVER=postgresql://postgres:mysecretpassword@host.docker.internal:5432/momentum Use this when using WSL | ||
POSTGRES_SERVER=postgresql://postgres:mysecretpassword@localhost:5432/momentum | ||
defaultUsername= defaultuser | ||
MONGO_URI=mongodb://127.0.0.1:27017 | ||
MONGODB_DB_NAME=momentum | ||
NEO4J_URI=bolt://127.0.0.1:7687 | ||
NEO4J_USERNAME=neo4j | ||
NEO4J_PASSWORD=mysecretpassword | ||
REDISHOST=127.0.0.1 | ||
REDISPORT=6379 | ||
BROKER_URL=redis://127.0.0.1:6379/0 | ||
CELERY_QUEUE_NAME=dev | ||
PORTKEY_API_KEY= | ||
GITHUB_PRIVATE_KEY= | ||
GITHUB_APP_ID= | ||
GCP_PROJECT= | ||
defaultUsername= defaultuser | ||
FIREBASE_SERVICE_ACCOUNT= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from fastapi import Depends, HTTPException | ||
from app.modules.auth.auth_service import AuthService | ||
from app.modules.github.github_service import GithubService | ||
|
||
class GithubController: | ||
@staticmethod | ||
def get_user_repos(user=Depends(AuthService.check_auth)): | ||
return GithubService.get_repos_for_user(user) | ||
|
||
@staticmethod | ||
def get_branch_list(repo_name: str, user=Depends(AuthService.check_auth)): | ||
return GithubService.get_branch_list(repo_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from fastapi import Depends, Query | ||
from app.modules.utils.APIRouter import APIRouter | ||
from app.modules.auth.auth_service import AuthService | ||
from .github_controller import GithubController | ||
|
||
router = APIRouter() | ||
|
||
@router.get("/github/user-repos") | ||
def get_user_repos(user=Depends(AuthService.check_auth)): | ||
return GithubController.get_user_repos(user=user) | ||
|
||
@router.get("/github/get-branch-list") | ||
def get_branch_list( | ||
repo_name: str = Query(..., description="Repository name"), | ||
user=Depends(AuthService.check_auth) | ||
): | ||
return GithubController.get_branch_list(repo_name=repo_name, user=user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from fastapi import Depends, HTTPException | ||
from starlette.responses import JSONResponse | ||
from app.core.database import get_db | ||
from app.modules.auth.auth_service import AuthService | ||
from app.modules.projects.projects_service import ProjectService | ||
|
||
class ProjectController: | ||
|
||
@staticmethod | ||
async def get_project_list(user=Depends(AuthService.check_auth), db = Depends(get_db)): | ||
user_id = user["user_id"] | ||
try: | ||
project_service = ProjectService(db) | ||
project_list = await project_service.list_projects(user_id) | ||
return project_list | ||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=str(e)) | ||
|
||
@staticmethod | ||
def delete_project(project_id: int, user=Depends(AuthService.check_auth), db=Depends(get_db)): | ||
project_service = ProjectService(db) | ||
try: | ||
project_service.delete_project(project_id) | ||
return JSONResponse( | ||
status_code=200, | ||
content={ | ||
"message": "Project deleted successfully.", | ||
"id": project_id | ||
} | ||
) | ||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=f"{str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from fastapi import Depends | ||
from app.modules.utils.APIRouter import APIRouter | ||
from app.modules.auth.auth_service import AuthService | ||
from app.core.database import get_db | ||
from .projects_controller import ProjectController | ||
|
||
router = APIRouter() | ||
|
||
@router.get("/projects/list") | ||
async def get_project_list(user=Depends(AuthService.check_auth), db=Depends(get_db)): | ||
return await ProjectController.get_project_list(user=user, db=db) | ||
|
||
@router.delete("/projects") | ||
def delete_project(project_id: int, user=Depends(AuthService.check_auth), db=Depends(get_db)): | ||
return ProjectController.delete_project(project_id=project_id, user=user, db=db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters