by iooi · 5y ago · 0 comments
I've looked at FastAPI before and it has some nice features like asyncio and pydantic integrations. But it doesn't have any official users library, and ideally a framework should have that available.
I've started looking outside of the Python ecosystem since it feels like there's nothing new and exciting come out of there. I've played around a bit with NestJS and it's amazing how far the TypeScript ecosystem has come.
It's also crazy that SQLAlchemy doesn't have typing support still, so TypeORM looks really appealing.
The tooling around REST APIs are lacking compared to Flask and FastAPI, but wrangling what's available (drf-yasg, oauth2lib) to suit my needs is better than migrating to another framework I think.
This partially due to the batteries included, partially because I am very familiar with it.
On more mature projects, at the stage where I really start splitting services into their own hosts, I switch to something else. Django's batteries are no longer useful at this stage, since e.g. auth is it's own service now.
About ORM with types, yeah, I also want an ORM based on standard type annotations. So I started playing with mixing SQLAlchemy and Pydantic, and I have some unfinished lab experiment with it.
I haven't found the time to finish it, but hopefully I'll find it soon.
With things like Hotwire and htmx you can build very nice feeling apps without going all-in with an API back-end and JS front-end.
I released https://github.com/nickjj/docker-flask-example as a starter kit for what I use in new projects. It wires up things like SQLAlchemy, Celery, Flask, gunicorn, Webpack, etc. with Docker. It also comes with CLI extensions for digesting / md5 tagging assets with optional CDN support using Flask-Static-Digest, database migrations / seeding with Flask-DB and more.
If I ever need to create API endpoints I combine Flask-Classful (routing), Marshmallow (serialization / validation) and Flask-JWT-Extended (authentication). I've written about this combo at: https://nickjanetakis.com/blog/flask-libraries-for-building-...
It provides a users framework with OAuth2 integration, support for different ORM backends, and routes for authentication, verification, etc.
Full disclosure: I am a contributor to this project.
Full disclosure: I'm the author of django-fastdev and co-author of iommi.