FastAPI Microservice Helper
Project description
FastAPI Request helper
How to use
- Set a variable
# user_service.py
from fastapi import FastAPI
from fastapi_global_variable import GlobalVariable
app = FastAPI(title="Application")
GlobalVariable.set('app', app)
- Use variable
from fastapi_global_variable import GlobalVariable
print(GlobalVariable.get_or_fail('app'))
print(GlobalVariable.get('app'))
- Decorators
FastAPI Request Helper provides lots of helpful decorators:
- Swagger docs decorators: @controller, @tag, @get, @post, @put, @delete, @patch
- Rate limit request: @rate_limit
- FastAPI response model: @response
- FastAPI guards: @guard, @gurads
- FastAPI response status: @status
- FastAPI API info details: @description, @summary, @name
- FastAPI API response status: @status_no_content, @status_ok, @status_created
- Hide API: @hidden_when(condition: boolean)
Fast API Helper also provides Pagination Query params helper: PaginationParams
# Sample
from fastapi_request_helper import (
controller,
post,
rate_limit,
response,
status_created,
status_no_content,
status_ok,
tag,
)
@controller('authentications')
@tag('Authentication')
class AuthenticationController:
def __init__(self, auth_service: AuthenticationService = Depends()):
self.auth_service = auth_service
@post('create-email-otp')
@status_no_content()
async def create_email_otp(self):
pass
How to test in testpypi
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_test.sh
How to publish new version
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_publish.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi_microservice_helper-0.0.32.tar.gz
.
File metadata
- Download URL: fastapi_microservice_helper-0.0.32.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e653ef2cf6dcc902e9abfdef03dcdff439cb4c5050c6ac8a2c8cc4960c1f6bb8 |
|
MD5 | 03c5b26ee9d1648efae577b3df875ffe |
|
BLAKE2b-256 | 75249044ba4ac89f29d0bdc21d21ac1033fb548d0d869850d03dee9a8fc2531d |
File details
Details for the file fastapi_microservice_helper-0.0.32-py3-none-any.whl
.
File metadata
- Download URL: fastapi_microservice_helper-0.0.32-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f3012b1f9a8c12d026b3ed6ea88c8c3e0b83ff4f9edd0a941cc6a90dee7816 |
|
MD5 | ac94c2aa3f39ba79da06596e6c216637 |
|
BLAKE2b-256 | 6febdd9bbc06b0078d41fcb664e2f20e6d076cbd0aa6c350829334373eaba228 |