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
Close
Hashes for fastapi_microservice_helper-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81e0d09163d0c2676e60385c6c2b270e3186818933c89579b33e103181832474 |
|
MD5 | c89f84dda49fa0d0f7fd8632c72c56e9 |
|
BLAKE2b-256 | dc7ea72fb7e1f439e6a12e4885416108cf558f74913d721aec780cfe8a29341c |
Close
Hashes for fastapi_microservice_helper-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 036925b74618821d9b9b9fb6ed517f387604167ab750c8a14b63aa41b758105c |
|
MD5 | 25b8f652583fbd1942bafe0ca79bcfcd |
|
BLAKE2b-256 | f490cae8b235a7d6bb236dc6686001a8d76ee25dafce79c3d46a71af7d2de39b |