
Security News
New CNA Scorecard Tool Ranks CVE Data Quality Across the Ecosystem
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Bazario is a lightweight, expressive library for routing requests and notifications to the right handlers with ease. Designed for modular applications, it simplifies your codebase while staying powerful and flexible.
Install Bazario with pip:
pip install bazario
Define what you want to do with a Request
and specify how it’s handled:
# application/requests/create_user.py
from bazario import Request, RequestHandler
class CreateUserRequest(Request[str]):
def __init__(self, username: str):
self.username = username
class CreateUserHandler(RequestHandler[CreateUserRequest, str]):
def handle(self, request: CreateUserRequest) -> str:
return f"User {request.username} created!"
Use Notification
to broadcast events:
# application/notifications/user_created.py
from bazario import Notification, NotificationHandler
class UserCreatedNotification(Notification):
def __init__(self, user_id: str):
self.user_id = user_id
class UserCreatedHandler(NotificationHandler[UserCreatedNotification]):
def handle(self, notification: UserCreatedNotification) -> None:
print(f"Notification: User {notification.user_id} was created.")
Set up your Dispatcher
to handle requests and notifications seamlessly:
# bootstap/ioc.py
from bazario import Dispatcher, Resolver, Sender, Publisher
from bazario.resolvers.your_di_framework import YourDIFrameworkResolver
from your_di_framework import Container
def provide_registry() -> Registry:
registry = Registry()
registry.add_request_handler(CreateUserRequest, CreateUserHandler)
registry.add_notification_handlers(UserCreatedNotification, UserCreatedHandler)
return registry
def provide_resolver(container: Container) -> Resolver:
return YourDIFrameworkResolver(container)
def provide_dispatcher(registry: Registry, resolver: Resolver) -> Dispatcher:
return Dispatcher(resolver, registry)
def provide_container() -> Container:
container = Container()
container.register(Registry, provide_registry)
container.register(Resolver, provide_resolver)
container.register(Dispatcher, provide_dispatcher)
container.register_aliases(Dispatcher, aliases=[Sender, Publisher])
return container
# presentation/rest/users.py
from your_framework import post
from your_di_framework import inject
from bazario import Sender, Publisher
from application.requests.create_user import CreateUserRequest
from application.notifications.user_created import UserCreatedNotification
@post("/")
@inject
def create_user(sender: Sender, publisher: Publisher) -> None:
response = sender.send(CreateUserRequest("john_doe"))
print(response) # Output: User john_doe created!
publisher.publish(UserCreatedNotification("123")) # Output: Notification: User 123 was created.
Bazario is optimized for synchronous in-memory processing and handler routing, making it ideal for applications requiring modularity, simplicity, and flexible handler management.
FAQs
Lightweight handler routing library for modular apps.
We found that bazario demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.