Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@neighbourhoodie/adonis-kafka
Advanced tools
Adonis Kafka provides an easy way to start using Kafka.
npm i @neighbourhoodie/adonis-kafka
node ace configure @neighbourhoodie/adonis-kafka
Edit the .env
file to match your Kafka configuration.
Edit the config/kafka.js
file to edit the default configuration.
Create your consumer in start/kafka.js
. Ex:
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
const consumer = Kafka.createConsumer({ groupId: 'default'})
consumer.on({ topic: 'messages' }, (data: any, commit: any) => {
console.log(data)
// commit(false) // For error transaction
commit() // For successful transaction
});
consumer.start()
}
Or create a kafka controller:
node ace make controller kafka/webhooks
// app/controllers/kafka/webhooks_controller
// import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
export default class WebhooksController {
async handleWebhook(data: any, commit: any) {
console.log('received in controller', data)
commit()
}
}
// start/kafka.ts
import WebhooksController from '#controllers/kafka/webhooks_controller'
const consumer = Kafka.createConsumer({ groupId: 'default' })
consumer.on({ topic: 'messages' }, [WebhooksController, 'handleWebhook'])
consumer.start()
const consumer = Kafka.createConsumer({ groupId: 'default' })
consumer.on('messages', [WebhooksController, 'handleWebhook'])
consumer.registerErrorHandler('messsages', (error) => {
console.log('got error!', error)
})
consumer.start()
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
const consumer = Kafka.createConsumer({ groupId: 'default'})
consumer.on({ topic: 'messages' }, (data: any, commit: any, { heartbeat, pause }) => {
console.log(data)
// I might need some extra time processing my message
await heartbeat()
// or pause processing for a mo
// await pause()
commit() // For successful transaction
});
consumer.start()
}
At the moment, only JSON.parse()
errors are handled.
Create your producer in app/Controllers/
for example, or in any other place. Ex:
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
import type { HttpContext } from '@adonisjs/core/http'
export default class UserController {
constructor() {
Kafka.createProducer('myProducer', {} /* ProducerConfig */).start()
}
public async show({ params, kafka: { producers } }: HttpContext) {
return producers['myProducer'].send('messages', { user_id: params.id })
}
}
// file: start/kafka.js
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
Kafka.admin.listTopics().then((topics: any[]) => {
console.log('topics', topics);
});
// file: start/kafka.js
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
Kafka.admin.createTopics({
topics: [
{
topic: 'messages',
numPartitions: 1,
replicationFactor: 1,
},
],
waitForLeaders: true,
}).then((result: any) => {
console.log('result', result);
});
This package uses KafkaJS, so you can use all commands from KafkaJS. Ex:
import Kafka from "@neighbourhoodie/adonis-kafka/services/kafka";
Kafka.admin.describeCluster().then((result: any) => {
console.log('result', result);
})
FAQs
Adonis Kafka provides an easy way to start using Kafka.
The npm package @neighbourhoodie/adonis-kafka receives a total of 1 weekly downloads. As such, @neighbourhoodie/adonis-kafka popularity was classified as not popular.
We found that @neighbourhoodie/adonis-kafka demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.