Skip to content

Commit

Permalink
fix/docs: cache config and fix swagger link
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Aug 17, 2024
1 parent 26fbe61 commit 1356a16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ You can install the required dependencies for your editor with the following.
poetry install
```

You can spin the server up locally with the following. You can access the Swagger UI at [localhost:7860/api/docs](http://localhost:7860/api/docs).
You can spin the server up locally with the following. You can access the Swagger UI at [localhost:7860/schema/swagger](http://localhost:7860/schema/swagger).

```bash
docker build -f Dockerfile.build -t capgen .
docker run --rm -e APP_PORT=7860 -p 7860:7860 capgen
docker run --rm -e SERVER_PORT=7860 -p 7860:7860 capgen
```
21 changes: 20 additions & 1 deletion server/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
from typing import TypeVar
from functools import lru_cache
from typing import Callable, TypeVar

from pydantic_settings import BaseSettings

T = TypeVar('T')


def cache(user_function: Callable[[type[T]], T]) -> Callable[[type[T]], T]:
"""
Summary
-------
a specific decorator to cache the result of a function
Parameters
----------
user_function (Callable[[type[T]], T]) : the function to cache
Returns
-------
wrapper (Callable[[type[T]], T]) : the wrapper function
"""
return lru_cache(maxsize=None)(user_function)


@cache
def singleton(cls: type[T]) -> T:
"""
Summary
Expand Down

0 comments on commit 1356a16

Please sign in to comment.