diff --git a/api/advent22_api/config.py b/api/advent22_api/config.py index b1e1ac6..43bc9ff 100644 --- a/api/advent22_api/config.py +++ b/api/advent22_api/config.py @@ -10,9 +10,13 @@ class User(BaseModel): password: str +class Puzzle(BaseModel): + solution: str + + class Config(BaseModel): admin: User - solution: str + puzzle: Puzzle async def get_config() -> Config: diff --git a/api/advent22_api/routers/_misc.py b/api/advent22_api/routers/_misc.py index 9780670..68a929e 100644 --- a/api/advent22_api/routers/_misc.py +++ b/api/advent22_api/routers/_misc.py @@ -17,7 +17,7 @@ from ._image import AdventImage async def get_rnd(bonus_salt: Any = "") -> random.Random: cfg = await get_config() - return random.Random(f"{cfg.solution}{bonus_salt}") + return random.Random(f"{cfg.puzzle.solution}{bonus_salt}") async def set_length(seq: Sequence, length: int) -> list: @@ -44,7 +44,7 @@ async def get_letter( index: int, cfg: Config = Depends(get_config), ) -> str: - return (await shuffle(cfg.solution))[index] + return (await shuffle(cfg.puzzle.solution))[index] _RE_IMAGE_FILE = re.compile( diff --git a/api/advent22_api/routers/days.py b/api/advent22_api/routers/days.py index a17ff98..d564d86 100644 --- a/api/advent22_api/routers/days.py +++ b/api/advent22_api/routers/days.py @@ -15,8 +15,8 @@ router = APIRouter(prefix="/days", tags=["days"]) @router.on_event("startup") async def startup() -> None: cfg = await get_config() - print(cfg.solution) - print("".join(await shuffle(cfg.solution))) + print(cfg.puzzle.solution) + print("".join(await shuffle(cfg.puzzle.solution))) @router.get("/letter/{index}") @@ -24,7 +24,7 @@ async def get_letter( index: int, cfg: Config = Depends(get_config), ) -> str: - return (await shuffle(cfg.solution))[index] + return (await shuffle(cfg.puzzle.solution))[index] @router.get("/date")