Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
apphook
is a way to implant/modify other piece of code.
It is a lightweight Event-Manager that inspired by Wordpress Hooks
Computer software is a sort of sequence. We build software according to the business.
However, the user's behaviors are out-of-sequence and chaos.
You will never know what users want, how they use your software, what they want to customization.
So, we need to prepare a system to deal with out-of-sequence and chaos, which can make big changes and flexible customization available.
That's why we should know AppHook
.
AppHook
is a hooks engine which Event-Driven. It can intercept users' behaviors and extend our functionalities.
npm i --save apphook
TypeScript types declarations (.d.ts) are ready.
See examples for usage examples.
We place AppHook hooks in code and trigger event.
For example, when user click the button A, we can trigger a event called "click:button:A"
We have two way to trigger event:
// Window.tsx
// ...
onClickLoginButton: () => {
// ...
apphook.doTrigger('user:click_login_button');
}
// ...
// EventTracking.ts, a independent file for event tracking
apphook.addTrigger('user:click_login_button', (args) => {
// Event Tracking Code
EventTracking.track('user:click_login_button', {...});
tracker.track('user:click_login_button', {...});
tracker.setProfile({email:'xxx@xxx.com'});
});
apphook.addFilter('get_form_name', (defaultValue, args) => {
let user = args[0];
if (user.is_cloud) {
return "Member ID";
} else if (user.is_self_hosted) {
return "Employee ID";
}
return defaultValue;
});
// UI.tsx
<Form name="{apphook.applyFilters('get_form_name', 'ID')}" />
// Here will get the result "Member ID" or "Employee ID" or "ID"
If you want:
When a female user get into your product the 10 times, popup "congratulation, you have used 10 times"
Break it down:
Relevant code:
// trigger event
apphook.doTrigger('application:start', [], 10) // the 10th times get in
// add trigger
apphook.addTrigger('application:start', (args, hookState) => {
if (hookState == 10) {
showWindow('congratulation, you have used 10 times');
}
}, {
doCheck: (args) => {
return user.gender === 'female';
}});
FAQs
A way to implant/modify other piece of code
We found that apphook demonstrated a not healthy version release cadence and project activity because the last version was released 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.