@liad123121/whalo-common 1.0.4 → 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.
@@ -0,0 +1,3 @@
1
+ declare const initKafka: () => Promise<void>;
2
+ export { initKafka };
3
+ //# sourceMappingURL=connection.d.ts.map
@@ -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,6 @@
1
+ declare enum EVENT_TOPICS {
2
+ PLAYER_CREATED = "player.created",
3
+ PLAYER_DELETED = "player.deleted"
4
+ }
5
+ export { EVENT_TOPICS };
6
+ //# sourceMappingURL=types.d.ts.map
@@ -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
@@ -1,2 +1,3 @@
1
- export * from "./types";
1
+ export * from "./events/types";
2
+ export * from "./events/connection";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,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,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,YAAY;IACf,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CAClC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,YAAY;IACf,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CAClC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;AACnC,CAAC,EAHI,YAAY,4BAAZ,YAAY,QAGhB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;AACnC,CAAC,EAHI,YAAY,4BAAZ,YAAY,QAGhB"}
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@liad123121/whalo-common",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc && cp ./package.json ./dist",
9
- "publish": "npm run build && npm version patch && npm publish --access public --prefix ./dist"
8
+ "build": "tsc && cp ./package.json ./build",
9
+ "publish-package": "npm run build && npm version patch && cd ./build && npm publish --access public"
10
10
  },
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
  }
package/dist/package.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@liad123121/whalo-common",
3
- "version": "1.0.3",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc && cp ./package.json ./dist",
9
- "publish": "npm run build && npm version patch && npm publish --access public --prefix ./dist"
10
- },
11
- "keywords": [],
12
- "author": "",
13
- "license": "ISC",
14
- "type": "commonjs"
15
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./types";
package/src/types.ts DELETED
@@ -1,6 +0,0 @@
1
- enum EVENT_TOPICS {
2
- PLAYER_CREATED = "player.created",
3
- PLAYER_DELETED = "player.deleted",
4
- }
5
-
6
- export { EVENT_TOPICS };
package/tsconfig.json DELETED
@@ -1,44 +0,0 @@
1
- {
2
- // Visit https://aka.ms/tsconfig to read more about this file
3
- "compilerOptions": {
4
- // File Layout
5
- // "rootDir": "./src",
6
- "outDir": "./dist",
7
-
8
- // Environment Settings
9
- // See also https://aka.ms/tsconfig/module
10
- "module": "nodenext",
11
- "target": "esnext",
12
- "types": [],
13
- // For nodejs:
14
- // "lib": ["esnext"],
15
- // "types": ["node"],
16
- // and npm install -D @types/node
17
-
18
- // Other Outputs
19
- "sourceMap": true,
20
- "declaration": true,
21
- "declarationMap": true,
22
-
23
- // Stricter Typechecking Options
24
- "noUncheckedIndexedAccess": true,
25
- "exactOptionalPropertyTypes": true,
26
-
27
- // Style Options
28
- // "noImplicitReturns": true,
29
- // "noImplicitOverride": true,
30
- // "noUnusedLocals": true,
31
- // "noUnusedParameters": true,
32
- // "noFallthroughCasesInSwitch": true,
33
- // "noPropertyAccessFromIndexSignature": true,
34
-
35
- // Recommended Options
36
- "strict": true,
37
- "jsx": "react-jsx",
38
- "verbatimModuleSyntax": false,
39
- "isolatedModules": true,
40
- "noUncheckedSideEffectImports": true,
41
- "moduleDetection": "force",
42
- "skipLibCheck": true
43
- }
44
- }