🔧 Refactor of config to add it in DB for admin part

master
Alix JEUDI--LEMOINE 1 week ago
parent 868b09f7ef
commit 5b4615da67

@ -9,16 +9,33 @@ MONGODB_DATABASE = os.getenv("MONGODB_DATABASE", "memorymap")
# Constants for JWT
SECRET_KEY = os.getenv("JWT_SECRET_KEY", "_2YfT44$xF.Tg_xI63UH3D7:N+>pZN2';j%>7H@?e0:Xor'pV[") # temporary of course :)
ALGORITHM = os.getenv("JWT_ALGORITHM", "HS256")
ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("JWT_ACCESS_TOKEN_EXPIRE_MINUTES", 30)) # TODO: check what to add here / maybe need to evaluate criticity of that?
ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("JWT_ACCESS_TOKEN_EXPIRE_MINUTES", 30))
# Constants for OAuth2
TOKEN_URL = "/api/v1/login" # Path to the auth
# Constants for images
UPLOAD_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "images")
MAX_IMAGE_SIZE = 8 * 1024 * 1024 # 8 Mo
ALLOWED_MIME_TYPES = [
"image/jpeg",
"image/png",
"image/heic"
]
# Constants for config
UPLOAD_DIR = os.getenv("UPLOAD_DIR", os.path.join(os.path.dirname(os.path.dirname(__file__)), "images"))
# Configuration par défaut du système
DEFAULT_CONFIG = {
"max_image_size": 8 * 1024 * 1024, # 8MB
"max_images_per_pin": 10,
"max_images_per_user": 100,
"allowed_image_types": [
"image/jpeg",
"image/png",
"image/gif",
"image/webp"
],
"max_pins_per_user": 50,
"max_friends_per_user": 100
}
# Configuration actuelle (sera mise à jour au démarrage)
MAX_IMAGE_SIZE = DEFAULT_CONFIG["max_image_size"]
MAX_IMAGES_PER_PIN = DEFAULT_CONFIG["max_images_per_pin"]
MAX_IMAGES_PER_USER = DEFAULT_CONFIG["max_images_per_user"]
ALLOWED_MIME_TYPES = DEFAULT_CONFIG["allowed_image_types"]
MAX_PINS_PER_USER = DEFAULT_CONFIG["max_pins_per_user"]
MAX_FRIENDS_PER_USER = DEFAULT_CONFIG["max_friends_per_user"]

@ -0,0 +1,16 @@
from pydantic import BaseModel
from typing import List
from datetime import datetime
class SystemConfig(BaseModel):
max_image_size: int # en octets
max_images_per_pin: int
max_images_per_user: int
allowed_image_types: List[str] # types MIME
max_pins_per_user: int
max_friends_per_user: int
class DBConfig(BaseModel):
config: SystemConfig
updated_at: datetime
updated_by: str # ID de l'utilisateur qui a fait la dernière modification
Loading…
Cancel
Save