Skip to content

Commit 3cc2715

Browse files
committed
Docker compose manifest
1 parent a779275 commit 3cc2715

13 files changed

+31
-24
lines changed
File renamed without changes.

app/server/app.py renamed to app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@app.get("/", tags=["Root"])
1212
async def read_root():
13-
return {"message": "Welcome to this fantastic app, sighs."}
13+
return {"message": "Welcome to this fantastic app."}
1414

1515

1616
app.include_router(AdminRouter, tags=["Administrator"], prefix="/admin")

app/server/auth/admin.py renamed to auth/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from fastapi.security import HTTPBasicCredentials, HTTPBasic
33
from passlib.context import CryptContext
44

5-
from app.server.database.database import admin_collection
5+
from database.database import admin_collection
66

77
security = HTTPBasic()
88
hash_helper = CryptContext(schemes=["bcrypt"])

app/server/auth/jwt_bearer.py renamed to auth/jwt_bearer.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# Code copied from github.com/overrideveloper/HowAreYouApi*
21
from fastapi import Request, HTTPException
32
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
43

54
from .jwt_handler import decodeJWT
6-
# from models.Database import Database
75

86

97
class JWTBearer(HTTPBearer):
10-
# db: Database = None
118

129
def __init__(self, auto_error: bool = True):
1310
super(JWTBearer, self).__init__(auto_error=auto_error)
14-
# self.db = db
1511

1612
async def __call__(self, request: Request):
1713
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)

app/server/auth/jwt_handler.py renamed to auth/jwt_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ def decodeJWT(token: str) -> dict:
2727
decoded_token = jwt.decode(token.encode(), JWT_SECRET, algorithms=["HS256"])
2828
return decoded_token if decoded_token['expires'] >= time.time() else None
2929
except:
30-
return None
30+
return {}

app/server/database/database.py renamed to database/database.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from bson import ObjectId
33
from decouple import config
44

5-
from app.server.database.database_helper import student_helper, admin_helper
5+
from database.database_helper import student_helper, admin_helper
66

77
MONGO_DETAILS = config('MONGO_DETAILS')
88

File renamed without changes.

docker-compose.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: "3"
2+
3+
services:
4+
web:
5+
build: .
6+
ports:
7+
- 8080:8080
8+
env_file:
9+
- .env
10+
11+
mongodb:
12+
image: bitnami/mongodb:latest
13+
ports:
14+
- 27017
15+
volumes:
16+
- data:/bitnami/mongodb
17+
18+
19+
volumes:
20+
data:

app/main.py renamed to main.py

File renamed without changes.
File renamed without changes.
File renamed without changes.

app/server/routes/admin.py renamed to routes/admin.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from fastapi.security import HTTPBasicCredentials
44
from passlib.context import CryptContext
55

6-
from server.database.database import admin_collection
7-
#from app.server.auth.admin import validate_login
8-
from server.auth.jwt_handler import signJWT
9-
from server.database.database import add_admin
10-
from server.models.admin import AdminModel
6+
from database.database import admin_collection
7+
from auth.jwt_handler import signJWT
8+
from database.database import add_admin
9+
from models.admin import AdminModel
1110

1211
router = APIRouter()
1312

@@ -27,14 +26,6 @@ async def admin_login(admin_credentials: HTTPBasicCredentials = Body(...)):
2726

2827
return "Incorrect email or password"
2928

30-
# OLD CODE
31-
# if validate_login(admin):
32-
# return {
33-
# "email": admin.username,
34-
# "access_token": signJWT(admin.username)
35-
# }
36-
# return "Invalid Login Details!"
37-
3829
@router.post("/")
3930
async def admin_signup(admin: AdminModel = Body(...)):
4031
admin_exists = await admin_collection.find_one({"email": admin.email}, {"_id": 0})

app/server/routes/student.py renamed to routes/student.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from fastapi import APIRouter, Body
22
from fastapi.encoders import jsonable_encoder
33

4-
from app.server.database.database import *
5-
from app.server.models.student import *
4+
from database.database import *
5+
from models.student import *
66

77
router = APIRouter()
88

@@ -21,7 +21,7 @@ async def get_student_data(id):
2121
student = await retrieve_student(id)
2222
return ResponseModel(student, "Student data retrieved successfully") \
2323
if student \
24-
else ErrorResponseModel("An error occured.", 404, "Student doesn'exist.")
24+
else ErrorResponseModel("An error occured.", 404, "Student doesn't exist.")
2525

2626

2727
@router.post("/", response_description="Student data added into the database")

0 commit comments

Comments
 (0)