
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Ksike Hook library for easy implementation of Event Driven Design. The Hooks pattern is a design pattern that facilitates event-driven programming within a software architecture. It allows you to define events and configure them with subscribers and notifiers. Subscribers listen to specific events and define which notifier should handle them when the event is triggered. This pattern enhances modularity and extensibility in event-driven systems.
This library belong to the Ksike ecosystem:
For further information, check the following topics:
The library comprises four key components: Hooks, Subscriber, Notifier, and Processor. These components work in tandem to provide a modular and customizable solution for managing events and executing actions based on event triggers.
Install the library:
npm install kshook
Load your custom notifier, subscriber, and processors:
const locator = require('./notifier.locator');
const { models, driver, manager } = require('./db');
Register subscribers for each event in the data model
------------------------------------------------------------------------------------------
| id | event | notifier | value | param | processor | expression |
------------------------------------------------------------------------------------------
| 1 | logout | locator | newrelic | null | null | null |
| 2 | login | locator | alert | { failure: dto.inf} | native | failure EQUAL 11 |
------------------------------------------------------------------------------------------
Extended model useful for workflows:
----------------------------------------------------------------------------------------------------------------------------------------
| id | event | notifier | value | param | processor | expression | notifier_alt | value_alt | param_alt |
----------------------------------------------------------------------------------------------------------------------------------------
| 1 | logout | locator | newrelic | null | null | null | null | null | null |
| 2 | login | locator | alert | {failure:dto.inf} | native | failure EQUAL 11 | email | test@srv.com | {note:dto.note} |
----------------------------------------------------------------------------------------------------------------------------------------
For more details check the workflow section.
Configure and run
const KsHook = require('kshook');
// Initialize KsHook instance
const hook = KsHook.get();
// Configure supported components
hook.notifier.set({
name: "locator",
target: locator
});
hook.subscriber.get("Model").configure({
models,
driver,
manager
});
// Trigger the 'login' event
const res = hook.trigger({
subscriber: ["Model"],
event: "login",
data: { failure: 10, flow: "6868465468415", step: "STEP-1" }
});
Explore the potential of dynamic event handling with KsHook, a library designed to empower developers with flexibility, extensibility, and seamless event-driven architecture.
FAQs
Ksike Hook library for easy implementation of Event Driven Design
We found that kshook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.