@epztickets/common 1.5.0 → 1.7.0
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,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ensureEventStream = ensureEventStream;
|
|
13
|
+
const nats_1 = require("nats");
|
|
14
|
+
const subjects_1 = require("../events/subjects");
|
|
15
|
+
function ensureEventStream(jsm) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const streams = yield jsm.streams.list().next();
|
|
18
|
+
const exists = streams.some(s => s.config.name === subjects_1.Streams.Events);
|
|
19
|
+
if (exists) {
|
|
20
|
+
console.log("Stream already exists:", subjects_1.Streams.Events);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
yield jsm.streams.add({
|
|
25
|
+
name: subjects_1.Streams.Events,
|
|
26
|
+
subjects: ["events.>"],
|
|
27
|
+
retention: nats_1.RetentionPolicy.Workqueue,
|
|
28
|
+
storage: nats_1.StorageType.File,
|
|
29
|
+
discard: nats_1.DiscardPolicy.Old,
|
|
30
|
+
max_age: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|