corebasic 1.0.52 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/features.js CHANGED
@@ -100,7 +100,7 @@ const commandAction = async (req, res, topic) => {
100
100
  try {
101
101
  let {data, feature, app, user, client, version} = req.body
102
102
  let params = req.params
103
- await Kafka.send(`Features.${topic}`, { data, params, feature, app, user, client, version, txn, id: _id, date: new Date().getTime() }, user)
103
+ await Kafka.send(`Features.${topic}`, { data, params, feature, app, user, client, version, txn, id: _id, date: new Date().getTime() }, user, { compression: Kafka.CompressionTypes.GZIP })
104
104
 
105
105
  } catch {
106
106
  throw {status: 500, message: "Failed to queue the transaction"}
package/libs/kafka.js CHANGED
@@ -1,6 +1,7 @@
1
- import { Kafka, logLevel as KafkaLogLevel } from 'kafkajs'
1
+ import { Kafka, logLevel as KafkaLogLevel, CompressionTypes as KafkaCompressionTypes } from 'kafkajs'
2
2
 
3
3
  export const logLevel = KafkaLogLevel
4
+ export const CompressionTypes = KafkaCompressionTypes
4
5
 
5
6
  let kafka, producer, admin
6
7
 
@@ -68,7 +69,7 @@ const start_consumer = async function (topic, groupId, callback) {
68
69
  // Producer
69
70
  // ===========
70
71
  let producerInvoked = false
71
- const start_producer = async function (topic, message, key) {
72
+ const start_producer = async function (topic, message, key, options) {
72
73
 
73
74
  let isJson = Object.prototype.toString.call(message) === '[object Object]' || Object.prototype.toString.call(message) === '[object Array]'
74
75
 
@@ -79,6 +80,7 @@ const start_producer = async function (topic, message, key) {
79
80
  let value = isJson ? JSON.stringify(message) : message
80
81
  await producer.send({
81
82
  topic: topic,
83
+ ...(options ?? {}),
82
84
  messages: [
83
85
  key ? { key, value} : {value},
84
86
  ],
@@ -99,9 +101,9 @@ export const receive = async function(topic, groupId, callback) {
99
101
  }
100
102
 
101
103
 
102
- export const send = async function(topic, message, key) {
104
+ export const send = async function(topic, message, key, options) {
103
105
  topic = topicPrefix + topic
104
- await start_producer(topic, message, key)
106
+ await start_producer(topic, message, key, options)
105
107
  }
106
108
 
107
109
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.52",
4
+ "version": "1.0.53",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {