-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathconfig.py
More file actions
49 lines (36 loc) · 1.56 KB
/
config.py
File metadata and controls
49 lines (36 loc) · 1.56 KB
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
import pathlib
from pydantic import AnyHttpUrl, EmailStr, validator
from pydantic_settings import BaseSettings
from typing import List, Optional, Union
# Project Directories
ROOT = pathlib.Path(__file__).resolve().parent.parent
class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
JWT_SECRET: str = "TEST_SECRET_DO_NOT_USE_IN_PROD"
ALGORITHM: str = "HS256"
# 60 minutes * 24 hours * 8 days = 8 days
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
# e.g: '["http://localhost", "http://localhost:4200", "http://localhost:3000", \
# "http://localhost:8080", "http://local.dockertoolbox.tiangolo.com"]'
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = [
"http://localhost:3000",
"http://localhost:8001", # type: ignore
]
# Origins that match this regex OR are in the above list are allowed
BACKEND_CORS_ORIGIN_REGEX: Optional[
str
] = "https.*\.(netlify.app|herokuapp.com)" # noqa: W605
@validator("BACKEND_CORS_ORIGINS", pre=True)
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
if isinstance(v, str) and not v.startswith("["):
return [i.strip() for i in v.split(",")]
elif isinstance(v, (list, str)):
return v
raise ValueError(v)
SQLALCHEMY_DATABASE_URI: Optional[str] = "sqlite:///example.db"
FIRST_SUPERUSER: EmailStr = "admin@recipeapi.com"
FIRST_SUPERUSER_PW: str = "CHANGEME"
class Config:
case_sensitive = True
settings = Settings()