-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
56 lines (39 loc) · 1.28 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from typing import Any
from enum import Enum
from jwcrypto.jwk import JWKSet
from pydantic import PostgresDsn, RedisDsn
from pydantic_settings import BaseSettings
class Environment(str, Enum):
DEVELOPMENT = "DEVELOPMENT"
TESTING = "TESTING"
PRODUCTION = "PRODUCTION"
@property
def is_debug(self):
return self in (self.DEVELOPMENT, self.TESTING)
@property
def is_testing(self):
return self == self.TESTING
@property
def is_deployed(self) -> bool:
return self in (self.PRODUCTION)
class Config(BaseSettings):
DATABASE_URL: PostgresDsn
REDIS_URL: RedisDsn
REDIS_BATCH_SIZE: int = 1000
JWKS_CACHE: JWKSet | None = None
JWKS_URL: str = "https://platform.pennlabs.org/identity/jwks/"
SITE_DOMAIN: str = "analytics.pennlabs.org"
ENVIRONMENT: Environment = Environment.PRODUCTION
CORS_ORIGINS: list[str] = ["*"]
CORS_ORIGINS_REGEX: str | None = None
CORS_HEADERS: list[str] = ["*"]
APP_VERSION: str = "1"
settings = Config()
app_configs: dict[str, Any] = {
"title": "Labs Analytics API",
"root_path": "",
}
if settings.ENVIRONMENT.is_deployed:
app_configs["root_path"] = f"/v{settings.APP_VERSION}"
if not settings.ENVIRONMENT.is_debug:
app_configs["openapi_url"] = None # hide docs