Skip to main content

A FastAPI application layer for the minumtium library.

Project description

Minumtium FastAPI

A FastAPI application layer for the minumtium library.

How it works

This library will provide you REST endpoints for authentication, user management and posts. It will use by default the Simple JWT Auth Adapter for authentication and the SQLite Adapter for data access/storage, but you can provide your own adapters if needed. Also, exposing the user management endpoints is optional, for the cases where you have your own user management and/or authentication systems and don't want to use the built-in ones.

This library is meant to be integrated into a bigger FastAPI application, so you can extend your application adding very simple blogging functionality to it.

Usage

Install it using your favorite package manager:

pip install minumtium-fastapi
pipenv install minumtium-fastapi
poetry install minumtium-fastapi

Then, get the FastAPI router to connect it as a subapp into your main FastAPI app:

from fastapi import FastAPI

import minumtium_fastapi

# Create the minumtium subapp
minumtium = minumtium_fastapi.get_minumtium_fastapi()

# Mount minumtium into your main application, with whatever prefix you would like
main_application = FastAPI()
main_application.mount('/minumtium', main_application)

You will get an instance that will use an in-memory sqlite and the standard JWT authentication when you call minumtium_fastapi.get_minumtium_fastapi() without passing any arguments.

Providing Custom Adapters

You can also provide your own adapters for data and authentication and disable the user management endpoints.

from fastapi import FastAPI

import minumtium_fastapi

from my_cool_app import MyCoolDatabaseAdapter, MyCoolAuthenticationAdapter

# Create your adapters
database_adapter_posts = MyCoolDatabaseAdapter('posts')
database_adapter_users = MyCoolDatabaseAdapter('users')
authentication_adapter = MyCoolAuthenticationAdapter()

# Create the minumtium subapp
minumtium = minumtium_fastapi.get_minumtium_fastapi(database_adapter_posts,
                                                    database_adapter_users,
                                                    include_user_endpoints=False)

# Mount minumtium into your main application, with whatever prefix you would like
main_application = FastAPI()
main_application.mount('/minumtium', main_application)

Running Standalone

You can also run it standalone, but this is probably useless. Create a file named main.py with the following contents:

from fastapi import FastAPI

import minumtium_fastapi

app = FastAPI()
app.mount('/minumtium', minumtium_fastapi.get_minumtium_fastapi())

Then execute it in the terminal:

uvicorn main:app --reload

API Docs

You will be able to see the API docs going to /<minumtium mount path>/docs in a running instance of minumtium.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minumtium_fastapi-1.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

minumtium_fastapi-1.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file minumtium_fastapi-1.1.0.tar.gz.

File metadata

  • Download URL: minumtium_fastapi-1.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for minumtium_fastapi-1.1.0.tar.gz
Algorithm Hash digest
SHA256 21d6e2bb33162736e77b3e8b4bea7a06baec472e28aa82a3e5114a3b94e87c55
MD5 ac2128fe1801022a74271e3977e489bb
BLAKE2b-256 1ca0adda51e37b94e5c64fb8f1ecac80b038e58a0267796d645774a943bba16d

See more details on using hashes here.

File details

Details for the file minumtium_fastapi-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for minumtium_fastapi-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bafde47392a0aba50fd48c7ad417321b12ae1a3365eec41425c0239ad5f12257
MD5 b5446692b5fd147f514702c8455b08cf
BLAKE2b-256 c3e4407f1179500e4b421fb49c9cada87133de5c5bcc154427d5f69b210f2c12

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page