@joystick.js/node-canary 0.0.0-canary.324 → 0.0.0-canary.326
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/app/index.js +3 -3
- package/dist/app/queues/index.js +16 -2
- package/package.json +1 -1
package/dist/app/index.js
CHANGED
|
@@ -71,7 +71,7 @@ class App {
|
|
|
71
71
|
this.initWebsockets(options?.websockets || {});
|
|
72
72
|
this.initAccounts(options?.accounts);
|
|
73
73
|
this.initTests();
|
|
74
|
-
this.
|
|
74
|
+
this.initPush();
|
|
75
75
|
this.initAPI(options?.api);
|
|
76
76
|
this.initUploaders(options?.uploaders);
|
|
77
77
|
this.initIndexes(options?.indexes);
|
|
@@ -278,8 +278,8 @@ class App {
|
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
if (process.env.NODE_ENV
|
|
281
|
+
initPush() {
|
|
282
|
+
if (process.env.NODE_ENV !== "development" && process.env.IS_PUSH_DEPLOYED) {
|
|
283
283
|
this.express.app.get("/api/_push/pre-version", async (req, res) => {
|
|
284
284
|
const instanceToken = fs.readFileSync("/root/push/instance_token.txt", "utf-8");
|
|
285
285
|
if (req?.headers["x-instance-token"] === instanceToken?.replace("\n", "")) {
|
package/dist/app/queues/index.js
CHANGED
|
@@ -31,7 +31,7 @@ class Queue {
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
return boundQueries;
|
|
34
|
-
}, {});
|
|
34
|
+
}, { _connection: db });
|
|
35
35
|
if (!is_external) {
|
|
36
36
|
await this.db.initializeDatabase(queuesDatabase);
|
|
37
37
|
if (this?.options?.runOnStartup) {
|
|
@@ -51,7 +51,21 @@ class Queue {
|
|
|
51
51
|
}
|
|
52
52
|
return process.databases._queues;
|
|
53
53
|
}
|
|
54
|
-
add(options = {}) {
|
|
54
|
+
async add(options = {}) {
|
|
55
|
+
const job_to_add = {
|
|
56
|
+
_id: generateId(),
|
|
57
|
+
status: "pending",
|
|
58
|
+
environment: process.env.NODE_ENV,
|
|
59
|
+
...options,
|
|
60
|
+
nextRunAt
|
|
61
|
+
};
|
|
62
|
+
const job_definition = this.options.jobs[options?.job];
|
|
63
|
+
if (job_definition && typeof job_definition?.preflight?.onBeforeAdd === "function") {
|
|
64
|
+
const canAddJob = await job_definition?.preflight?.onBeforeAdd(job_to_add, this.db._connection, this.name);
|
|
65
|
+
if (!canAddJob) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
55
69
|
const nextRunAt = options?.nextRunAt === "now" || !options?.nextRunAt ? new Date().toISOString() : options?.nextRunAt;
|
|
56
70
|
this.db.addJob({
|
|
57
71
|
_id: generateId(),
|