Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-zh committed Jul 13, 2023
1 parent dd64ad9 commit cd47381
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
12 changes: 11 additions & 1 deletion packages/kafka-avro-lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { AvroDecoder } from './avroDecoder';
import { AvroProducer } from './avroProducer';
import { getMessageHeaderValue } from './utils';
import { Action, HeaderNames, MessageHeaders, MessagePayload, TopicAvroSettings} from './types'

Check failure on line 4 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Replace `}·from·'./types'` with `·}·from·'./types';`

export { AvroProducer, AvroDecoder, getMessageHeaderValue };
export {

Check failure on line 6 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `·`
Action,

Check failure on line 7 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `··`
AvroProducer,

Check failure on line 8 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `··`
AvroDecoder,

Check failure on line 9 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Replace `····` with `··`
HeaderNames,

Check failure on line 10 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Replace `····` with `··`
getMessageHeaderValue,

Check failure on line 11 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `··`
MessageHeaders,

Check failure on line 12 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `··`
MessagePayload,

Check failure on line 13 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Delete `··`
TopicAvroSettings

Check failure on line 14 in packages/kafka-avro-lib/index.ts

View workflow job for this annotation

GitHub Actions / lint-test

Replace `····TopicAvroSettings` with `··TopicAvroSettings,`
};
2 changes: 1 addition & 1 deletion packages/kafka-avro-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@func-fun/kafka-avro-lib",
"version": "1.0.0-beta.0",
"version": "1.0.0-beta.1",
"type": "module",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/kafka-avro-lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export interface TopicAvroSettings {
compression?: number;
}

export type MessageHeaders = { [key in HeaderNames]?: string } | IHeaders;
export type MessageHeaders = { [key in HeaderNames]?: Buffer } | { [key: string]: Buffer };
export type MessagePayload = Record<string, string | number | boolean | Array<unknown> | Record<string, unknown>>;
6 changes: 4 additions & 2 deletions packages/kafka-avro-lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { HeaderNames, MessageHeaders } from './types';

export const getMessageHeaderValue = (headers: MessageHeaders, header: HeaderNames | string): string | null => {
for (const key in headers) {
if (header === key) {
return Buffer.from(headers[header]).toString();
const headerValue = headers[header as keyof MessageHeaders];

if (header === key && undefined !== headerValue) {
return Buffer.from(headerValue).toString();
}
}

Expand Down

0 comments on commit cd47381

Please sign in to comment.