
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@meeshkanml/http-types-kafka
Advanced tools
Tools for writing ts-http-types to Kafka in Node.js, powered by kafka.js.
First create the topic you're writing to:
$ kafka-topics.sh --bootstrap-server localhost:9092 --topic express_recordings --create --partitions 3 --replication-factor 1
Note that you may need to change script name depending on how you installed Kafka.
Create a HttpTypesKafkaProducer
and connect to Kafka:
// Create a `KafkaConfig` instance (from kafka.js)
const brokers = ["localhost:9092"];
const kafkaConfig: KafkaConfig = {
clientId: "client-id",
brokers,
};
// Specify the topic
const kafkaTopic = "express_recordings";
// Create the producer
const producer = HttpTypesKafkaProducer.create({ kafkaConfig, topic: kafkaTopic });
// Connect to Kafka
await producer.connect();
Send a single HttpExchange
to Kafka:
const exchange: HttpExchange = ...;
await producer.send(exchange);
Send multiple HttpExchanges
:
const exchanges: HttpExchange[] = ...;
await producer.sendMany(exchanges);
Send recordings from a JSON lines file, where every line is a JSON-encoded HttpExchange
:
await producer.sendFromFile("recordings.jsonl");
Finally, disconnect:
await producer.disconnect();
Delete the topic if you're done:
$ kafka-topics.sh --bootstrap-server localhost:9092 --topic express_recordings --delete
See available commands:
$ http-types-kafka
First create the destination topic in Kafka.
To send recordings from recordings.jsonl
to Kafka, run:
$ http-types-kafka producer --file=recordings.jsonl --topic=my_recordings
Install dependencies:
$ yarn
Build a package in lib
:
$ yarn compile
Run tests:
$ ./docker-start.sh # Start Kafka and zookeeper
$ yarn test
$ ./docker-stop.sh # Once you're done
Package for npm
:
$ npm pack
Publish to npm
:
$ npm publish --access public --dry-run
Remove --dry-run
once you're sure you want to publish.
First start kafka
and zookeeper
:
# See `docker-compose.yml`
docker-compose up
Create a topic called http_types_kafka_test
:
docker exec kafka1 kafka-topics --bootstrap-server kafka1:9092 --topic http_types_kafka_test --create --partitions 3 --replication-factor 1
Check the topic exists:
docker exec kafka1 kafka-topics --bootstrap-server localhost:9092 --list
Describe the topic:
docker exec kafka1 kafka-topics --bootstrap-server localhost:9092 --describe --topic http_types_kafka_test
List topics:
kafkacat -b localhost:9092 -L
Push data to topic from file with snappy
compression:
tail -f tests/resources/recordings.jsonl | kafkacat -b localhost:9092 -t http_types_kafka_test -z snappy
Consume messages from topic to console:
kafkacat -b localhost:9092 -t http_types_kafka_test -C
FAQs
Kafka producer for recording HTTP traffic
We found that @meeshkanml/http-types-kafka demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.