Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/litestar-org/litestar-pg-redis-docker
Example Litestar project using Postgresql, Redis and Docker
https://github.com/litestar-org/litestar-pg-redis-docker
api asgi docker hacktoberfest litestar litestar-api litestar-framework litestar-template postgresql python redis
Last synced: about 1 month ago
JSON representation
Example Litestar project using Postgresql, Redis and Docker
- Host: GitHub
- URL: https://github.com/litestar-org/litestar-pg-redis-docker
- Owner: litestar-org
- License: mit
- Created: 2022-01-06T20:42:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-29T06:27:31.000Z (about 1 year ago)
- Last Synced: 2024-08-28T21:14:47.756Z (4 months ago)
- Topics: api, asgi, docker, hacktoberfest, litestar, litestar-api, litestar-framework, litestar-template, postgresql, python, redis
- Language: Python
- Homepage:
- Size: 1.29 MB
- Stars: 157
- Watchers: 9
- Forks: 26
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-litestar - Litestar, PostgreSQL, Redis, SQLAlchemy
README
> [!WARNING]
> This repository has not been updated recently and will be receiving some TLC.
> Please see: [Discord discussion on litestar-pg-redis-docker](https://discord.com/channels/919193495116337154/1154552571025956985/1154552571025956985)
>
> If you would like to help, feel free to discuss in Discord or open a pull request.
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=coverage)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-pg-redis-docker&metric=bugs)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-pg-redis-docker)[![Discord](https://img.shields.io/discord/919193495116337154?color=202235&label=%20Discord&logo=discord)](https://discord.gg/X3FJqy8d2j)
[![Matrix](https://img.shields.io/badge/%5Bm%5D%20Matrix-bridged-blue?color=202235)](https://matrix.to/#/#litestarspace:matrix.org)
[![Reddit](https://img.shields.io/reddit/subreddit-subscribers/litestar?label=r%2FLitestar&logo=reddit)](https://reddit.com/r/litestar)# litestar-pg-redis-docker
This is an example [Litestar](https://github.com/litestar-api/litestar) project using SQLAlchemy + Alembic + postgresql,
Redis, SAQ and Docker.## Litestar
Litestar is a light and flexible ASGI API framework.
[Litestar documentation 📚](https://litestar-api.github.io/litestar/)
## Run the application
### Setup
- `$ cp .env.example .env`
- `$ docker compose build`
- `$ docker compose run --rm app alembic upgrade head`### Run
`$ docker compose up --build`
### Async Worker Emails
To demonstrate usage of the asynchronous `SAQ` workers, when an `Author` is created we trigger a
worker function that sends an email.`mailhog` is included in `docker-compose.yaml`, and includes a GUI that can be accessed at
`http://localhost:8025`.Create an `Author`:
```bash
$ curl -w "\n" -X POST -H "Content-Type: application/json" -d '{"name": "James Patterson", "dob": "1974-3-22"}' http://localhost:8000/v1/authors
{"id":"6f395bdf-3e77-481d-98b2-3471c2342654","created":"2022-10-09T23:18:10","updated":"2022-10-09T23:18:10","name":"James Patterson","dob":"1974-03-22"}
```Then check the `mailhog` GUI to see the email that has been sent by the worker.
## Development
### Install pre-commit hooks
- `pre-commit install`
### Migrations
#### Revision
`$ docker compose run --rm app alembic revision --autogenerate -m "revision description"`
#### Migration
`$ docker compose run --rm app alembic upgrade head`