Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devbruce/fastapi-di-tpl
FastAPI with Dependency Injector Template
https://github.com/devbruce/fastapi-di-tpl
dependency-injector fastapi template
Last synced: 2 months ago
JSON representation
FastAPI with Dependency Injector Template
- Host: GitHub
- URL: https://github.com/devbruce/fastapi-di-tpl
- Owner: devbruce
- License: mit
- Created: 2024-09-17T09:18:34.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-13T03:33:01.000Z (3 months ago)
- Last Synced: 2024-10-17T03:21:57.368Z (3 months ago)
- Topics: dependency-injector, fastapi, template
- Language: Python
- Homepage:
- Size: 113 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
FastAPI with Dependency Injector
> [!NOTE]
> This repository is a template of [FastAPI](https://fastapi.tiangolo.com/) with [Dependency Injector](https://python-dependency-injector.ets-labs.org/)## 📖 How to Set Local Environment
### 🛠️ Prerequisites
- [pyenv](https://github.com/pyenv/pyenv)
- [Poetry](https://python-poetry.org/)
- [direnv](https://direnv.net/)
### ✔️ Set Environment Variables
Copy [`.envrc.tpl`](./.envrc.tpl) to `.envrc` for setting environment variables with [direnv](https://direnv.net/)
```bash
cp .envrc.tpl .envrc
``````bash
direnv allow
```
### ✔️ Create Virtual Environment with [Poetry](https://python-poetry.org/)
Install python with [pyenv](https://github.com/pyenv/pyenv)
```bash
pyenv install ${PYTHON_VERSION}
```Set poetry config
```bash
poetry config virtualenvs.in-project true
```Create virtualenv(`.venv`) with poetry
```bash
poetry env use $(pyenv root)/versions/${PYTHON_VERSION}/bin/python
```Install python dependencies with poetry([`poetry.lock`](./poetry.lock))
```bash
poetry install
```Activate virtualenv(`.venv`) with poetry
```bash
poetry shell
```
### ✔️ Install pre-commit Hooks(`.git/hooks`)
> pre-commit: [Link](https://pre-commit.com/)
```bash
pre-commit install -t pre-commit
``````bash
pre-commit install -t pre-push
```
🖱️ Run Manually
```bash
pre-commit run
```
🖱️ How to Skip Hooks
After installing the hooks, you can use the `--no-verify` option to skip it.
```bash
git commit --no-verify
``````bash
git push --no-verify
```
> [!TIP]
> For details on the make commands, refer to the [`Makefile`](./Makefile)## 🚀 Run Server on Local
```bash
make run
```
## 💯 Test
```bash
make test
```
## ✅ Lint & Format
Check lint & format only
```bash
make check
```Format
```bash
make format
```
## 👤 Authors
- Maintainer: @devbruce