Starter template repo for dockerized aiohttp application, using gino and alembic
- Build
docker-compose build
- Generate initial migration
docker-compose run web alembic revision -m "Initialize schema" --autogenerate
- Initialize database
docker-compose run web alembic upgrade head
- Run app
docker-compose run web
$ curl localhost:8000/todo
{"todo": []}
$ curl -d '{"title":"Do the dishes"}' localhost:8000/tasks
{"task": {"id": 1, "title": "Do the dishes", "description": null, "is_completed": false}}
$ curl localhost:8000/todo
{"todo": [{"id": 1, "title": "Do the dishes", "description": null, "is_completed": false}]}
$ curl -X POST localhost:8000/tasks/1/complete
{"task": {"id": 1, "title": "Do the dishes", "description": null, "is_completed": true}}
$ curl localhost:8000/todo
{"todo": []}
Try to extend this starting point. Here are some ideas for what to incorporate:
- Authentication - OAuth, Token, JWT, etc
- Authorization - Different permission levels for different endpoints
- Response Serializers - Incorporate something like marshmallow to serialize complex objects
- Request Validation - Use a schema validation library like marshmallow to validate incoming requests
- General Error Handling - Catch errors in a middleware and format them consistently
- Production Environment - Set up a Kubernetes cluster and create the specifications to run the app there