1. Nessa aula vamos realizar as configurações iniciais do projeto.
  2. Vamos precisar instalar a biblioteca Python Decouple, para isso, vamos executar o comando pip install python-decouple.
  3. Vamos também criar o arquivo .env e passar algumas configurações nele.
JWT_SECRET_KEY=chavesecretaaqui
JWT_REFRESH_SECRET_KEY=chavesecretaaqui
MONGO_CONNECTION_STRING=mongodb://localhost:27017
4 - Vamos criar o arquivo config.py e adicionar o seguinte código:
# pip install python-decouple

from typing import List
from decouple import config
from pydantic.v1 import AnyHttpUrl, BaseSettings

class Settings(BaseSettings):
    API_V1_STR: str = '/api/v1'
    JWT_SECRET_KEY: str = config('JWT_SECRET_KEY', cast=str)
    JWT_REFRESH_SECRET_KEY: str = config('JWT_REFRESH_SECRET_KEY', cast=str)
    ALGORITHM ='HS256'
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60
    REFRESH_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 dias
    BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
    PROJECT_NAME: str = "TODOFast"
    
    # Database
    MONGO_CONNECTION_STRING: str = config("MONGO_CONNECTION_STRING", cast=str)
    
    class Config:
        case_sensitive = True
        
settings = Settings()