Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ezeparziale/fastapi-api-template
:zap: Fastapi Api template
https://github.com/ezeparziale/fastapi-api-template
alembic auth bcrypt black coverage docker docker-compose fastapi google isort jwt oauth2 postgres pydantic python ruff sqlalchemy swagger
Last synced: about 4 hours ago
JSON representation
:zap: Fastapi Api template
- Host: GitHub
- URL: https://github.com/ezeparziale/fastapi-api-template
- Owner: ezeparziale
- Created: 2022-09-05T00:30:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T21:54:30.000Z (8 months ago)
- Last Synced: 2024-05-22T22:46:04.050Z (8 months ago)
- Topics: alembic, auth, bcrypt, black, coverage, docker, docker-compose, fastapi, google, isort, jwt, oauth2, postgres, pydantic, python, ruff, sqlalchemy, swagger
- Language: Python
- Homepage:
- Size: 339 KB
- Stars: 4
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :zap: Fastapi api template
Template API with FastApi
## :floppy_disk: Installation
> [!IMPORTANT]
> Min Python version: 3.12Clone this repo:
```bash
git clone https://github.com/ezeparziale/fastapi-api-template
```Create virtual environment:
```bash
python -m venv env
```Activate environment:
- Windows:
```bash
. env/scripts/activate
```- Mac/Linux:
```bash
. env/bin/activate
```Upgrade pip:
```bash
python -m pip install --upgrade pip
```Install requirements:
```bash
pip install -r requirements-dev.txt
```Install pre-commit:
```bash
pre-commit install
```## :wrench: Config
Create `.env` file. Check the example `.env.example`
:globe_with_meridians: Google Auth credentials:
Create your app and obtain your `client_id` and `secret`:
```http
https://developers.google.com/workspace/guides/create-credentials
```:lock: How to create a secret key:
```bash
openssl rand -base64 64
```:construction: Before first run:
Run `docker-compose` :whale: to start the database server
```bash
docker compose -f "compose.yaml" up -d --build adminer db
```and init the database with alembic:
```bash
alembic upgrade head
```:key: Create a self-signed certificate with openssl:
```bash
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
```## :runner: Run
```bash
uvicorn app.main:app --reload --port 8000 --ssl-keyfile key.pem --ssl-certfile cert.pem
```## :pushpin: Features
- Basic login
- Google Auth login
- Create users
- Examples endpoints CRUD
- Posts
- Users
- Votes
- API healthcheck
- JWT tokens
- Middlewares
- CORS
- Complete swagger Api info
- Postgres## :rotating_light: Lint
Run linter and formatter
```bash
scripts/lint.sh
``````bash
scripts/format.sh
```## :technologist: Coverage
Run coverage
```bash
coverage run -m pytest
``````bash
coverage report --show-missing
``````bash
coverage html
```Or run all in one with:
```bash
scripts/coverage.sh
```## :test_tube: Test
Run pytest with coverage
```bash
coverage run -m pytest
```or
```bash
scripts/test.sh
```