@liad123121/whalo-common 1.0.5 → 1.0.6
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/dist/events/connection.d.ts +3 -0
- package/dist/events/connection.d.ts.map +1 -0
- package/dist/events/connection.js +34 -0
- package/dist/events/connection.js.map +1 -0
- package/dist/events/types.d.ts +6 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +9 -0
- package/dist/events/types.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/events/connection.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,qBA8Bd,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initKafka = void 0;
|
|
4
|
+
const kafkajs_1 = require("kafkajs");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const initKafka = async () => {
|
|
7
|
+
if (!process.env.KAFKA_BROKERS) {
|
|
8
|
+
throw new Error("Kafka broker addresses are not defined in environment variables");
|
|
9
|
+
}
|
|
10
|
+
if (!process.env.KAFKA_CLIENT_ID) {
|
|
11
|
+
throw new Error("Kafka client ID is not defined in environment variables");
|
|
12
|
+
}
|
|
13
|
+
const kafka = new kafkajs_1.Kafka({
|
|
14
|
+
clientId: process.env.KAFKA_CLIENT_ID,
|
|
15
|
+
brokers: process.env.KAFKA_BROKERS.split(","),
|
|
16
|
+
});
|
|
17
|
+
const admin = kafka.admin();
|
|
18
|
+
try {
|
|
19
|
+
await admin.connect();
|
|
20
|
+
await admin.createTopics({
|
|
21
|
+
waitForLeaders: true,
|
|
22
|
+
topics: Object.values(types_1.EVENT_TOPICS).map((topic) => ({
|
|
23
|
+
topic,
|
|
24
|
+
numPartitions: 1,
|
|
25
|
+
replicationFactor: 1,
|
|
26
|
+
})),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
await admin.disconnect();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.initKafka = initKafka;
|
|
34
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/events/connection.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,mCAAuC;AAEvC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC;QACtB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;QACrC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC;KAC9C,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,YAAY,CAAC;YACvB,cAAc,EAAE,IAAI;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAClD,KAAK;gBACL,aAAa,EAAE,CAAC;gBAChB,iBAAiB,EAAE,CAAC;aACrB,CAAC,CAAC;SACJ,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAEO,8BAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/events/types.ts"],"names":[],"mappings":"AAAA,aAAK,YAAY;IACf,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CAClC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVENT_TOPICS = void 0;
|
|
4
|
+
var EVENT_TOPICS;
|
|
5
|
+
(function (EVENT_TOPICS) {
|
|
6
|
+
EVENT_TOPICS["PLAYER_CREATED"] = "player.created";
|
|
7
|
+
EVENT_TOPICS["PLAYER_DELETED"] = "player.deleted";
|
|
8
|
+
})(EVENT_TOPICS || (exports.EVENT_TOPICS = EVENT_TOPICS = {}));
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/events/types.ts"],"names":[],"mappings":";;;AAAA,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;AACnC,CAAC,EAHI,YAAY,4BAAZ,YAAY,QAGhB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
__exportStar(require("./events/types"), exports);
|
|
18
|
+
__exportStar(require("./events/connection"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liad123121/whalo-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,5 +11,9 @@
|
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"author": "",
|
|
13
13
|
"license": "ISC",
|
|
14
|
-
"type": "commonjs"
|
|
14
|
+
"type": "commonjs",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@types/kafkajs": "^1.8.2",
|
|
17
|
+
"kafkajs": "^2.2.4"
|
|
18
|
+
}
|
|
15
19
|
}
|