@joystick.js/node-canary 0.0.0-canary.344 → 0.0.0-canary.346

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.
@@ -131,7 +131,6 @@ var queues_default = {
131
131
  CREATE TABLE IF NOT EXISTS queue_${this.queue.name} (
132
132
  _id text PRIMARY KEY,
133
133
  status text,
134
- environment text,
135
134
  job text,
136
135
  payload text,
137
136
  next_run_at text,
@@ -140,16 +139,17 @@ var queues_default = {
140
139
  completed_at text,
141
140
  failed_at text,
142
141
  error text,
142
+ environment text,
143
143
  attempts smallint
144
144
  )
145
145
  `);
146
- db?.query(`ALTER TABLE queue_${this.queue.name} ADD COLUMN IF NOT EXISTS attempts smallint`);
147
- db?.query(`ALTER TABLE queue_${this.queue.name} ADD COLUMN IF NOT EXISTS environment text`);
148
- db?.query(`CREATE INDEX IF NOT EXISTS status_index ON queue_${this.queue.name} (status)`);
149
- db?.query(`CREATE INDEX IF NOT EXISTS status_nextRunAt_index ON queue_${this.queue.name} (status, next_run_at)`);
150
- db?.query(`CREATE INDEX IF NOT EXISTS nextJob_index ON queue_${this.queue.name} (status, environment, next_run_at, locked_by)`);
151
- db?.query(`CREATE INDEX IF NOT EXISTS completedAt_index ON queue_${this.queue.name} (completed_at)`);
152
- db?.query(`CREATE INDEX IF NOT EXISTS failedAt_index ON queue_${this.queue.name} (failed_at)`);
146
+ await db?.query(`ALTER TABLE queue_${this.queue.name} ADD COLUMN IF NOT EXISTS environment text`);
147
+ await db?.query(`ALTER TABLE queue_${this.queue.name} ADD COLUMN IF NOT EXISTS attempts smallint`);
148
+ await db?.query(`CREATE INDEX IF NOT EXISTS status_index ON queue_${this.queue.name} (status)`);
149
+ await db?.query(`CREATE INDEX IF NOT EXISTS status_nextRunAt_index ON queue_${this.queue.name} (status, next_run_at)`);
150
+ await db?.query(`CREATE INDEX IF NOT EXISTS nextJob_index ON queue_${this.queue.name} (status, environment, next_run_at, locked_by)`);
151
+ await db?.query(`CREATE INDEX IF NOT EXISTS completedAt_index ON queue_${this.queue.name} (completed_at)`);
152
+ await db?.query(`CREATE INDEX IF NOT EXISTS failedAt_index ON queue_${this.queue.name} (failed_at)`);
153
153
  if (this.queue.options?.cleanup?.completedAfterSeconds) {
154
154
  cron.schedule("*/30 * * * * *", () => {
155
155
  handleCleanupQueues({
@@ -1,3 +1,5 @@
1
+ const KILOBYTE = 1e3;
2
+ const MEGABYTE = KILOBYTE * 1e3;
1
3
  const HTML_ENTITY_MAP = {
2
4
  "&": "&",
3
5
  "<": "&lt;",
@@ -9,5 +11,7 @@ const HTML_ENTITY_MAP = {
9
11
  "=": "&#x3D;"
10
12
  };
11
13
  export {
12
- HTML_ENTITY_MAP
14
+ HTML_ENTITY_MAP,
15
+ KILOBYTE,
16
+ MEGABYTE
13
17
  };
@@ -0,0 +1,21 @@
1
+ import { MongoClient } from "mongodb";
2
+ import { MEGABYTE } from "../lib/constants.js";
3
+ const connectMongoDB = async () => {
4
+ const client = new MongoClient("mongodb://localhost:27017");
5
+ const db = client.db("push");
6
+ await db.collection("logs").drop();
7
+ await db.collection("metrics").drop();
8
+ await db.createCollection("logs", { capped: true, size: MEGABYTE * 50, max: 1e3 });
9
+ await db.createCollection("metrics", { capped: true, size: MEGABYTE * 50, max: 1e3 });
10
+ await db.collection("logs").createIndex({ timestamp: 1 });
11
+ await db.collection("metrics").createIndex({ timestamp: 1 });
12
+ await client.connect();
13
+ return {
14
+ client,
15
+ db
16
+ };
17
+ };
18
+ var connectMongoDB_default = connectMongoDB;
19
+ export {
20
+ connectMongoDB_default as default
21
+ };
@@ -1,7 +1,5 @@
1
- import { MongoClient } from "mongodb";
2
1
  import timestamps from "../../lib/timestamps";
3
- const KILOBYTE = 1e3;
4
- const MEGABYTE = KILOBYTE * 1e3;
2
+ import connectMongoDB from "../connectMongoDB.js";
5
3
  const captureLog = (callback = null) => {
6
4
  process.stdout.write = (data) => {
7
5
  if (callback) {
@@ -24,22 +22,8 @@ const captureLog = (callback = null) => {
24
22
  }
25
23
  });
26
24
  };
27
- const connectMongoDB = async () => {
28
- const client = new MongoClient("mongodb://localhost:27017");
29
- const db = client.db("push");
30
- try {
31
- await db.createCollection("logs", { capped: true, size: MEGABYTE * 50, max: 1e3 });
32
- await db.createCollection("metrics", { capped: true, size: MEGABYTE * 50, max: 1e3 });
33
- } catch {
34
- }
35
- await client.connect();
36
- return {
37
- client,
38
- db
39
- };
40
- };
41
- const writeLogsToDisk = () => {
42
- captureLog(async (source = "", data = "") => {
25
+ var logs_default = () => {
26
+ return captureLog(async (source = "", data = "") => {
43
27
  const mongodb = await connectMongoDB();
44
28
  switch (source) {
45
29
  case "stdout":
@@ -65,9 +49,6 @@ const writeLogsToDisk = () => {
65
49
  }
66
50
  });
67
51
  };
68
- var logs_default = () => {
69
- return writeLogsToDisk();
70
- };
71
52
  export {
72
53
  logs_default as default
73
54
  };
@@ -4,10 +4,10 @@ var websockets_default = (serverName = "") => {
4
4
  return {
5
5
  send: (payload = {}, uniqueConnectionId = "") => {
6
6
  const emitterName = uniqueConnectionId ? `${serverName}_${uniqueConnectionId}` : serverName;
7
+ emitWebsocketEvent(emitterName, "message", payload);
7
8
  trackFunctionCall(`node.websockets.${serverName}.send`, [
8
9
  payload
9
10
  ]);
10
- emitWebsocketEvent(emitterName, "message", payload);
11
11
  }
12
12
  };
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
- "version": "0.0.0-canary.344",
3
+ "version": "0.0.0-canary.346",
4
4
  "type": "module",
5
5
  "description": "A Node.js framework for building web apps.",
6
6
  "main": "./dist/index.js",