@joystick.js/node-canary 0.0.0-canary.351 → 0.0.0-canary.353
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/index.js +3 -1
- package/dist/push/connectMongoDB.js +0 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,9 @@ import pushLogs from "./push/logs/index.js";
|
|
|
17
17
|
import nodeUrlPolyfills from "./lib/nodeUrlPolyfills.js";
|
|
18
18
|
import sendEmail from "./email/send";
|
|
19
19
|
const { readFile } = fs.promises;
|
|
20
|
-
|
|
20
|
+
if (process.env.NODE_ENV !== "development" && process.env.IS_PUSH_DEPLOYED) {
|
|
21
|
+
await pushLogs();
|
|
22
|
+
}
|
|
21
23
|
const generate_sql_from_object = _generate_sql_from_object;
|
|
22
24
|
const accounts = _accounts;
|
|
23
25
|
const action = _action;
|
|
@@ -4,24 +4,15 @@ const connect_mongodb = async () => {
|
|
|
4
4
|
const client = await MongoClient.connect("mongodb://localhost:27017");
|
|
5
5
|
const db = client.db("push");
|
|
6
6
|
await db.collection("logs").drop();
|
|
7
|
-
await db.collection("metrics").drop();
|
|
8
7
|
const existing_collections = (await db.listCollections().toArray())?.map((collection) => collection?.name);
|
|
9
8
|
const has_logs_collection = existing_collections?.includes("logs");
|
|
10
|
-
const has_metrics_collection = existing_collections?.includes("metrics");
|
|
11
9
|
if (!has_logs_collection) {
|
|
12
10
|
await db.createCollection("logs", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
13
11
|
}
|
|
14
|
-
if (!has_metrics_collection) {
|
|
15
|
-
await db.createCollection("metrics", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
16
|
-
}
|
|
17
12
|
const logs_index = (await db.collection("logs").listIndexes().toArray())?.find((index) => index?.name === "timestamp_1");
|
|
18
|
-
const metrics_index = (await db.collection("metrics").listIndexes().toArray())?.find((index) => index?.name === "timestamp_1");
|
|
19
13
|
if (!logs_index) {
|
|
20
14
|
await db.collection("logs").createIndex({ timestamp: 1 });
|
|
21
15
|
}
|
|
22
|
-
if (!metrics_index) {
|
|
23
|
-
await db.collection("metrics").createIndex({ timestamp: 1 });
|
|
24
|
-
}
|
|
25
16
|
return db;
|
|
26
17
|
};
|
|
27
18
|
var connectMongoDB_default = connect_mongodb;
|