Giter Club home page Giter Club logo

starlite-pg-redis-docker's Introduction

Starlite Logo - Light Starlite Logo - Dark

Quality Gate Status Coverage Technical Debt Maintainability Rating Reliability Rating Vulnerabilities Bugs

Discord Matrix Reddit

starlite-pg-redis-docker

This is an example Starlite project using SQLAlchemy + Alembic + postgresql, Redis, SAQ and Docker.

Starlite

Starlite is a light and flexible ASGI API framework.

Starlite documentation ๐Ÿ“š

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:

$ 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

Test

To run the tests, have tox installed and on your path. I recommend pipx which is a tool for installing python applications in isolated environments.

Install pipx

python3 -m pip install --user pipx
python3 -m pipx ensurepath

Install tox

pipx install tox

You'll now be able to run $ pipx run tox, but that's still a little verbose. I choose to add an alias for this, e.g.,:

# ~/.bashrc
# ...
alias tox="pipx run tox"

Close and reopen your shell, or $ source ~/.bashrc to get the alias working in your current shell.

Linting

tox -e lint
# run a specific hook
tox -e lint mypy

Unit tests

tox -e test

Integration tests

tox -e integration

starlite-pg-redis-docker's People

Contributors

peterschutt avatar dependabot[bot] avatar goldziher avatar yudjinn avatar sondrelg avatar cofin avatar danielgafni avatar grillazz avatar ekeric13 avatar jacobcoffee avatar provinzkraut avatar v3ss0n avatar sorasful avatar mookrs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.