Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@osskit/dafka-producer-fetch-client

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@osskit/dafka-producer-fetch-client - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "@osskit/dafka-producer-fetch-client",
"version": "0.0.3",
"version": "0.0.4",
"repository": {

@@ -5,0 +5,0 @@ "url": "https://github.com/osskit/dafka-producer-fetch-client"

<div align="center">
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/osskit/dafka-producer-fetch-client/publish) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/osskit/dafka-producer-fetch-client/blob/master/LICENSE.md) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/osskit/dafka-producer-fetch-client/publish.yml) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/osskit/dafka-producer-fetch-client/blob/master/LICENSE.md) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

@@ -13,13 +13,24 @@ typescript-fetch client wrapper for `dafka-producer`

## Usage
### Scoped
```ts
import { createProducer } from '@osskit/dafka-producer-fetch-client'
import { createProducer } from '@osskit/dafka-producer-fetch-client';
export const produce = createProducer<TEventData>('https://my-dafka-producer-url', 'my-topic', 'my-partition-key');
export const produce = createProducer<Message>({
url: 'http://dafka-producer',
topic: 'my-topic',
keyExtractor: (record) => record.id,
fetch: global.fetch,
});
await produce<TEventData>(payload);
await produce(records);
```
### Extra headers
It is possible to add extra headers to the request
```ts
await produce(records, {
'x-extra-header': 'value',
});
```
## API
### createProducer(url: string, topic: string, key?: string)
### createProducer({ url, topic, keyExtractor, fetch })
#### url

@@ -35,11 +46,16 @@ Type: `string`

#### key
Type: `string`
#### keyExtractor
Type: `(record: Record) => string`
The Kafka Topic Partition key, if not supplied then a random UUID is generated
A function to extract the key from a record, defaults to a random `UUID`
#### fetch
Type: `typeof global.fetch`
The fetch function to use
#### returns
An instance of a function that receives `<T>(payload: T)`
An instance of a function that receives `<Record>(records: Record[], extraHeaders?: object)` and returns `Promise<void>`
## License
[MIT License](LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc