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.2 to 0.0.3

10

dist/producer.d.ts

@@ -1,1 +0,9 @@

export declare const createProducer: <T>(url: string, topic: string) => (payload: T, key?: string) => Promise<Response>;
type Fetch = typeof global.fetch;
export interface ProducerOptions<Record> {
url: string;
topic: string;
fetch: Fetch;
keyExtractor?: (record: Record) => string;
}
export declare const createProducer: <Record_1>({ url, topic, fetch, keyExtractor }: ProducerOptions<Record_1>) => (records: Record_1[], extraHeaders?: object) => Promise<void>;
export {};

29

dist/producer.js
import { randomUUID } from 'node:crypto';
const toProduceRequest = (key, topic, value) => ({
const toKafkaRecord = (key, topic, value) => ({
topic,

@@ -7,9 +7,22 @@ key,

});
const produce = (payload, url, topic, key) => fetch(url, {
method: 'POST',
body: JSON.stringify(Array.isArray(payload)
? payload.map((p) => toProduceRequest(key ?? randomUUID(), topic, p))
: [toProduceRequest(key ?? randomUUID(), topic, payload)]),
});
export const createProducer = (url, topic) => (payload, key) => produce(payload, url, topic, key);
const produce = async ({ records, url, keyExtractor, fetch, topic, extraHeaders, }) => {
await fetch(url, {
method: 'POST',
body: JSON.stringify(records.map((record) => toKafkaRecord(keyExtractor?.(record) ?? randomUUID(), topic, record))),
headers: {
...extraHeaders,
'content-type': 'application/json',
},
});
};
export const createProducer = ({ url, topic, fetch, keyExtractor }) => async (records, extraHeaders) => {
await produce({
fetch,
records,
url,
topic,
keyExtractor,
extraHeaders,
});
};
//# sourceMappingURL=producer.js.map
{
"name": "@osskit/dafka-producer-fetch-client",
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -30,21 +30,22 @@ "url": "https://github.com/osskit/dafka-producer-fetch-client"

"devDependencies": {
"@osskit/eslint-config": "^1.0.11",
"@jest/globals": "^29.7.0",
"@osskit/eslint-config": "^1.0.21",
"@osskit/prettier-config": "^0.0.1",
"@osskit/tsconfig": "^0.0.6",
"@osskit/wiremock-client": "^4.2.0",
"@types/jest": "^29.1.2",
"@types/node": "^18.11.0",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"eslint": "^8.25.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.2",
"eslint-plugin-unicorn": "^44.0.2",
"husky": "^8.0.1",
"jest": "^29.2.0",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"@osskit/wiremock-client": "^4.3.2",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"eslint": "^8.54.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-unicorn": "^49.0.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "^5.3.2"
},

@@ -51,0 +52,0 @@ "lint-staged": {

Sorry, the diff of this file is not supported yet

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