Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
hapi-class-extension-points
Advanced tools
Changelog
2.1.0 - 2020-06-22
server.extClass
decorationReadme
Use class methods to add lifecycle extension points to your hapi server.
Installation · Usage · Contribute
Follow @marcuspoehls for updates!
The Future Studio University supports development of this hapi plugin 🚀
Join the Future Studio University and Skyrocket in Node.js
This hapi plugin adds the server.extClass(class)
decoration to register lifecycle extensions from class methods.
hapi v19 (or later) and Node.js v12 (or newer)
This plugin requires hapi v19 (or later) and Node.js v12 or newer.
Major Release | hapi.js version | Node.js version |
---|---|---|
v2 | >=17 hapi | >=12 |
v1 | >=17 hapi | >=8 |
Add hapi-class-extension-points
as a dependency to your project:
npm i hapi-class-extension-points
Register hapi-class-extension-points
to your hapi server. This will decorate the hapi server
with a server.extClass()
method:
await server.register({
plugin: require('hapi-class-extension-points')
})
// went smooth like chocolate :)
// now your hapi server supports 'server.extClass(class MyMiddleware {})'
Having the plugin registered, you can now write your lifecycle extension points as classes:
class RateLimiting {
constructor (server) {
this.server = server
}
async onRequest (request, h) {
// rate limit the request
await this.handle(request)
return h.continue
}
async handle (request) {
// this is a private method that won't be registered as a lifecycle extension
}
onPreResponse (request, h) {
// add rate limiting headers
return h.continue
}
}
server.extClass(RateLimiting)
That's it! The constructor of your class receives the hapi server. You can then store it as a class property and use it when needed!
Enjoy!
git checkout -b my-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT © Future Studio
futurestud.io · GitHub @futurestudio · Twitter @futurestud_io
FAQs
hapi plugin that registers lifecycle extension points from class methods
We found that hapi-class-extension-points 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.