This release is a pre-release and may not be stable for production use.
steroid
Steroid is a Python library built on top of FastAPI, designed to provide developers with a framework for building high-performance APIs using a structured architecture inspired by NestJs.
Installation
$ pip install steroid
Usage
import pydantic
from fastapi import Header, HTTPException, Request
from steroid import Controller, CreateApp, Get, Middleware, Post, UseMiddlewares
class Salute(pydantic.BaseModel):
aye: str
class AuthMiddleware(Middleware):
HOOK = "POST"
def action(request: Request):
authToken = request.headers.get("Authorization")
if authToken is None or not authToken:
raise HTTPException(status_code=401, detail="Unauthorized")
class PreMiddleware(Middleware):
HOOK = "PRE"
def action(request: Request):
print("hello")
class PostMiddleware(Middleware):
HOOK = "POST"
def action(request: Request):
print("bye")
@Controller("greetings")
class GreetController:
@Get("greet/{pk}/{gID}")
def Greet(
pk: str,
gID: int,
authorization: str = Header(alias="Authorization", default=None),
):
return {"hello": {"pk": pk, "gID": gID, "XToken": authorization}}
@UseMiddlewares(AuthMiddleware)
@Post("no-greet")
def NoGreet(salute: Salute):
return {"noHello": salute}
@Controller("clutch")
class CluthController:
@UseMiddlewares(PreMiddleware, PostMiddleware)
@Get("savage")
def Savage():
return {"hello": "clutchers, savage, and everything else"}
@Get("not-a-savage")
def NotASavage():
return {"hello": "clutchers, not a savage, and everything else"}
def main():
app = CreateApp()
app.addController(GreetController)
app.addController(CluthController)
app.start()
if __name__ == "__main__":
main()
Start server
$ python example.py
[23/07/2023, 19:19:57] INFO [Controller] GreetController {/greetings}
[23/07/2023, 19:19:57] INFO [Method] Mapped {/greetings/greet/{pk}/{gID}, GET} route
[23/07/2023, 19:19:57] INFO [Method] Mapped {/greetings/no-greet, POST} route
[23/07/2023, 19:19:57] INFO [Controller] CluthController {/clutch}
[23/07/2023, 19:19:58] INFO [Method] Mapped {/clutch/savage, GET} route
[23/07/2023, 19:19:58] INFO [Method] Mapped {/clutch/not-a-savage, GET} route
Metadata
Release files for steroid 0.16b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| steroid-0.16b0.tar.gz | 6.4 kB | Without provenance | Details for steroid-0.16b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| steroid-0.16b0-py3-none-any.whl | Python 3 | none | any | Details for steroid-0.16b0-py3-none-any.whl |
Total release size: 14.3 kB
Release files / steroid-0.16b0.tar.gz
| Download URL | steroid-0.16b0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
691287d9f3ea0fadc7c9c406df02cf553a2f7cbdccce0a20e33460a5b3a59d54
|
|
BLAKE2b-256 checksum How to use checksums |
701ba1ab6a8c646d6c16fb9362bf17262007a6b984bf7f4e6a827e6bca84e53f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/6.5.0-1016-azure
|
Release files / steroid-0.16b0-py3-none-any.whl
| Download URL | steroid-0.16b0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8812d4b7e2849d55e1c2535ae5ee64ca4170723215aee67f0beebf3d522d00fa
|
|
BLAKE2b-256 checksum How to use checksums |
71970155ac8e1554625f9d395655c1ceaf1b3bdc05d88f5a63b1080a044e69aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/6.5.0-1016-azure
|
Security for steroid 0.16b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.