init
This commit is contained in:
37
app/core/config.py
Normal file
37
app/core/config.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from functools import lru_cache
|
||||
from typing import List
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", env_ignore_empty=True)
|
||||
|
||||
PROJECT_NAME: str = "NautilusDesk API"
|
||||
SECRET_KEY: str = "change-me"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60
|
||||
|
||||
POSTGRES_SERVER: str = "localhost"
|
||||
POSTGRES_PORT: int = 5432
|
||||
POSTGRES_USER: str = "postgres"
|
||||
POSTGRES_PASSWORD: str = "postgres"
|
||||
POSTGRES_DB: str = "nautilusdesk"
|
||||
DATABASE_URL: str | None = None
|
||||
|
||||
BACKEND_CORS_ORIGINS: List[str] = []
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
if self.DATABASE_URL:
|
||||
return self.DATABASE_URL
|
||||
return (
|
||||
f"postgresql+psycopg2://{self.POSTGRES_USER}:"
|
||||
f"{self.POSTGRES_PASSWORD}@{self.POSTGRES_SERVER}:"
|
||||
f"{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
||||
)
|
||||
|
||||
|
||||
@lru_cache
|
||||
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user