webfast 0.1.82 → 0.1.84
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/README.md +19 -0
- package/app/content/js/webfast.js +19 -9
- package/index.js +1 -1
- package/modules/data/mongo/aggregate.js +48 -48
- package/package.json +1 -1
package/README.md
CHANGED
@@ -112,6 +112,25 @@ routes
|
|
112
112
|
Within these folders, you can establish a dynamic setup, as exemplified in the module itself.
|
113
113
|
|
114
114
|
```
|
115
|
+
## program.modules.dependOn
|
116
|
+
example :
|
117
|
+
```
|
118
|
+
module.exports = {
|
119
|
+
dependOn: ['express.app','modules.data'],
|
120
|
+
name: '{UNIQUE_NAME}',
|
121
|
+
run: async function (program, name,functions) {
|
122
|
+
},
|
123
|
+
functions : {
|
124
|
+
}
|
125
|
+
}
|
126
|
+
```
|
127
|
+
To add an dependOn function
|
128
|
+
```
|
129
|
+
program.modules.dependOn({REQUIRE},program,`{UNIQUE_NAME}-sync`,function(){
|
130
|
+
console.log(`Depend On CallBack`);
|
131
|
+
});
|
132
|
+
```
|
133
|
+
|
115
134
|
## License
|
116
135
|
|
117
136
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
@@ -127,6 +127,16 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
127
127
|
web.fast.que.state = true;
|
128
128
|
|
129
129
|
//alert(web.fast.tools.isMobile);
|
130
|
+
var generateRandomId = async function(length) {
|
131
|
+
var result = '';
|
132
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
133
|
+
var charactersLength = characters.length;
|
134
|
+
for (var i = 0; i < length; i++) {
|
135
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
136
|
+
}
|
137
|
+
return result;
|
138
|
+
};
|
139
|
+
|
130
140
|
function arraySend() {
|
131
141
|
try {
|
132
142
|
if (web.fast.user != undefined && web.fast.inial == undefined || window.Telegram.WebApp.initData == `` && web.fast.inial == undefined) {
|
@@ -134,16 +144,8 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
134
144
|
jQuery(`[webfast-get]`).each(async function(){
|
135
145
|
const type = jQuery(this).attr(`webfast-get`);
|
136
146
|
let id = jQuery(this).attr(`id`);
|
147
|
+
console.log(`THE GET`);
|
137
148
|
if (id == undefined) {
|
138
|
-
var generateRandomId = async function(length) {
|
139
|
-
var result = '';
|
140
|
-
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
141
|
-
var charactersLength = characters.length;
|
142
|
-
for (var i = 0; i < length; i++) {
|
143
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
144
|
-
}
|
145
|
-
return result;
|
146
|
-
};
|
147
149
|
id = await generateRandomId(8); // Generate a random ID of length 8
|
148
150
|
}
|
149
151
|
arraySend.push({
|
@@ -183,6 +185,7 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
183
185
|
// We have user data
|
184
186
|
console.log(`Set User Data`);
|
185
187
|
web.fast.user = json;
|
188
|
+
|
186
189
|
// Now go Through to set all data
|
187
190
|
// Get all webfast client
|
188
191
|
jQuery(`[webfast-client]`).each(function(){
|
@@ -224,6 +227,13 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
224
227
|
|
225
228
|
web.fast.que.state = Date.now();
|
226
229
|
web.fast.receive(`socket`,event.data); // Placeholder for processing response
|
230
|
+
jQuery(document).ready(function(){
|
231
|
+
try {
|
232
|
+
web.fast.tools.on.connect();
|
233
|
+
} catch (err) {
|
234
|
+
console.error(`error getting connect data`);
|
235
|
+
}
|
236
|
+
})
|
227
237
|
} catch (err) {
|
228
238
|
console.error(`Error Receiving`);
|
229
239
|
console.error(event);
|
package/index.js
CHANGED
@@ -112,7 +112,7 @@ module.exports = async function (array) {
|
|
112
112
|
|
113
113
|
// Now include this thing then
|
114
114
|
try {
|
115
|
-
program.modules[reqFunc.name] = await reqFunc.run(program,reqFunc.name);
|
115
|
+
program.modules[reqFunc.name] = await reqFunc.run(program,reqFunc.name,reqFunc.functions);
|
116
116
|
if (callback != undefined) {
|
117
117
|
return callback(program,name)
|
118
118
|
} else {
|
@@ -1,52 +1,52 @@
|
|
1
1
|
const { MongoClient } = require('mongodb');
|
2
|
-
module.exports = async function(program,db,collection,query,callback) {
|
3
|
-
// Ensure the MongoDB connection string is provided
|
4
|
-
// Ensure the MongoDB connection string is provided
|
5
|
-
if (!process.env.mongo) {
|
6
|
-
console.error('MongoDB connection string not provided. Set process.env.mongo.');
|
7
|
-
process.exit(1);
|
8
|
-
}
|
9
|
-
|
10
|
-
// Define the MongoDB URI
|
11
|
-
const uri = process.env.mongo;
|
12
|
-
|
13
|
-
// Define the database and collection name
|
14
|
-
const dbName = db;
|
15
|
-
const collectionName = collection;
|
16
|
-
|
17
|
-
async function main() {
|
18
|
-
// Create a new MongoClient
|
19
|
-
const client = new MongoClient(uri);
|
20
|
-
|
21
|
-
try {
|
22
|
-
// Connect to the MongoDB server
|
23
|
-
await client.connect();
|
24
|
-
console.log('Connected to the MongoDB server');
|
25
2
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
3
|
+
module.exports = async function (program, db, collection, pipeline, one = false) {
|
4
|
+
// Ensure the MongoDB connection string is provided
|
5
|
+
if (!process.env.mongo) {
|
6
|
+
console.error('MongoDB connection string not provided. Set process.env.mongo.');
|
7
|
+
process.exit(1);
|
8
|
+
}
|
9
|
+
|
10
|
+
// Define the MongoDB URI
|
11
|
+
const uri = process.env.mongo;
|
12
|
+
|
13
|
+
// Define the database and collection name
|
14
|
+
const dbName = db;
|
15
|
+
const collectionName = collection;
|
16
|
+
|
17
|
+
async function main() {
|
18
|
+
// Create a new MongoClient
|
19
|
+
const client = new MongoClient(uri);
|
20
|
+
|
21
|
+
try {
|
22
|
+
// Connect to the MongoDB server
|
23
|
+
await client.connect();
|
24
|
+
console.log('Connected to the MongoDB server');
|
25
|
+
|
26
|
+
// Select the database
|
27
|
+
const database = client.db(dbName);
|
28
|
+
|
29
|
+
// Select the collection
|
30
|
+
const collection = database.collection(collectionName);
|
31
|
+
|
32
|
+
// Perform the aggregation query
|
33
|
+
let result = await collection.aggregate(pipeline).toArray();
|
34
|
+
|
35
|
+
if (one) {
|
36
|
+
result = result[0];
|
37
|
+
}
|
38
|
+
|
39
|
+
// Process the result
|
40
|
+
console.log('Aggregation result:', result);
|
41
|
+
return result;
|
42
|
+
} catch (error) {
|
43
|
+
console.error('Error executing MongoDB aggregation:', error);
|
44
|
+
} finally {
|
45
|
+
// Close the MongoDB connection
|
46
|
+
await client.close();
|
47
47
|
}
|
48
|
+
}
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
50
|
+
// Execute the main function
|
51
|
+
return await main().catch(console.error);
|
52
|
+
};
|