Commit c491f760 authored by deepdey's avatar deepdey

chore: update response config

parent 8ddf56d5
SUCCESS_CODE: int = 200
VALIDATION_ERROR_CODE: int = 403
SUCCESS_CODE: int = 201
VALIDATION_ERROR_CODE: int = 400
EXCEPTION_CODE: int = 500
UN_AUTHORIZED_CODE: int = 401
\ No newline at end of file
......@@ -55,8 +55,6 @@ class Login(Resource):
if not bcrypt.check_password_hash(user_info.password, password):
return prepare_api_response(401, 'Invalid password')
# fetch user role info
api_key = self.generate_api_key()
process_valid_loging(user_info, api_key)
......
......@@ -9,7 +9,7 @@ def prepare_swagger_response(
data: any = None
) -> dict:
response: dict = {
'code': fields.Integer(default=code),
'status_code': fields.Integer(default=code),
'message': fields.String(default=message)
}
......@@ -27,7 +27,7 @@ def prepare_api_response(
) -> dict:
response: dict = {
'code': int(code),
'status_code': int(code),
'message': str(message)
}
......@@ -35,6 +35,6 @@ def prepare_api_response(
response['data'] = data
if (error is not None):
response['error'] = error
response['errors'] = error
return response, code
from typing import Optional
import redis
from app.app_config.config import REDIS_HOST, REDIS_PORT, REDIS_DATABASE
......@@ -21,10 +22,13 @@ def get_value(key: str) -> str | None:
return None
def set_value(key: str,value: str) -> bool:
def set_value(key: str,value: str, expire_time: Optional[int] = None) -> bool:
try:
client = get_client(REDIS_HOST, REDIS_PORT, None)
client.set(key, value)
if expire_time:
client.set(key, value, ex=expire_time)
else:
client.set(key, value)
return True
except Exception as e:
print(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment