Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Minimal FastAPI template with async tests setup and Supertokens integration

License

Notifications You must be signed in to change notification settings

execreate/fastapi-supertokens-template

Repository files navigation

FastAPI + Supertokens template

A simple starting point for your FastAPI application that uses Supertokens for user auth.

About

The template includes the following to help you to get started:

  1. Makefile for dependency management with pip-tools
  2. Dockerfile and compose files for local development
  3. SQLAlchemy for ORM (uses async engine) and Alembic for database migrations
  4. Simple authentication for docs page
  5. CRUD operations generic class with pagination
  6. Support for API versioning (https://api.yourdomain.com/v1/)

TODO:

  • Tests are yet to come

How to use

Make sure to mark the app/ folder as source in your IDE otherwise you'll get import errors. And since all your code (except tests) lives inside app/ folder, you should import modules like this:

from core.config import settings

and NOT like this:

# this will throw an error!
from app.core.config import settings

Start coding

Just click on that green Use this template button to start coding. There is a dummy app that is already implemented for you so that you can quickly learn how to use the CRUD factory.

Local setup

The following command will start a Postgres database and a Supertokens core locally in Docker:

docker compose -f docker-compose-local.yml up -d

so that you can do

cd app; uvicorn main:app

Otherwise, if you want to build a docker container with your app and run it, you can use the other compose file:

docker compose -f docker-compose-test.yml up -d

If you run the command above without changing the code, you can find the documentation page here. The default username is docs_user and the password is simple_password.

About

Minimal FastAPI template with async tests setup and Supertokens integration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published