webfast 0.1.68 → 0.1.70

Sign up to get free protection for your applications and to get access to all the features.
@@ -125,34 +125,13 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
125
125
  console.log('WebSocket connected');
126
126
  // Start other things (e.g., send initial data)
127
127
  web.fast.que.state = true;
128
-
129
128
  //alert(web.fast.tools.isMobile);
130
- function arraySend() {
129
+ function arraySendFunction() {
131
130
  try {
132
- if (web.fast.user != undefined || window.Telegram.WebApp.initData == ``) {
131
+ if (web.fast.que.state == false || window.Telegram.WebApp.initData == ``) {
133
132
  let arraySend = [];
134
- jQuery(`[webfast-get]`).each(async function(){
135
- const type = jQuery(this).attr(`webfast-get`);
136
- let id = jQuery(this).attr(`id`);
137
- 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
- id = await generateRandomId(8); // Generate a random ID of length 8
148
- }
149
- arraySend.push({
150
- id : id,
151
- type : type
152
- })
153
- })
154
- console.log(`Send Array`,arraySend);
155
- web.fast.tools.on.connect(arraySend);
133
+ //alert(`Connected`);
134
+
156
135
  } else {
157
136
  if (countedError < 3) {
158
137
  console.error(`Tried 10 times`);
@@ -163,13 +142,14 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
163
142
 
164
143
  }
165
144
  } catch (err) {
145
+ alert(`err`);
166
146
  setTimeout(function(){
167
- arraySend();
147
+ arraySendFunction();
168
148
  },200);
169
149
  }
170
150
  }
171
151
  // send array
172
- arraySend();
152
+ arraySendFunction();
173
153
 
174
154
  };
175
155
 
@@ -183,6 +163,7 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
183
163
  // We have user data
184
164
  console.log(`Set User Data`);
185
165
  web.fast.user = json;
166
+
186
167
  // Now go Through to set all data
187
168
  // Get all webfast client
188
169
  jQuery(`[webfast-client]`).each(function(){
@@ -224,6 +205,32 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
224
205
 
225
206
  web.fast.que.state = Date.now();
226
207
  web.fast.receive(`socket`,event.data); // Placeholder for processing response
208
+
209
+ let arraySend = [];
210
+ jQuery(`[webfast-get]`).each(async function(){
211
+ const type = jQuery(this).attr(`webfast-get`);
212
+ let id = jQuery(this).attr(`id`);
213
+ if (id == undefined) {
214
+ var generateRandomId = async function(length) {
215
+ var result = '';
216
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
217
+ var charactersLength = characters.length;
218
+ for (var i = 0; i < length; i++) {
219
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
220
+ }
221
+ return result;
222
+ };
223
+ id = await generateRandomId(8); // Generate a random ID of length 8
224
+ }
225
+ arraySend.push({
226
+ id : id,
227
+ type : type
228
+ })
229
+ })
230
+ console.log(`Send Array`,arraySend);
231
+ web.fast.tools.on.connect(arraySend);
232
+ web.fast.que.state = true;
233
+
227
234
  } catch (err) {
228
235
  console.error(`Error Receiving`);
229
236
  console.error(event);
@@ -11,15 +11,6 @@ module.exports = async function(db,collection,query,one = false,array) {
11
11
  process.exit(1);
12
12
  }
13
13
 
14
- function routeExists(path) {
15
- return program.express.app._router.stack.some(layer => {
16
- if (layer.route) {
17
- return layer.route.path === path;
18
- }
19
- return false;
20
- });
21
- }
22
-
23
14
  // Define the MongoDB URI
24
15
  const uri = process.env.mongo;
25
16
 
@@ -53,6 +44,16 @@ module.exports = async function(db,collection,query,one = false,array) {
53
44
  // Process the result
54
45
  console.log('Query result:', result);
55
46
 
47
+
48
+ async function routeExists(path) {
49
+ return program.express.app._router.stack.some(layer => {
50
+ if (layer.route) {
51
+ return layer.route.path === path;
52
+ }
53
+ return false;
54
+ });
55
+ }
56
+
56
57
  // Check if profile image to get it from db
57
58
  if (result.profileImage != undefined && array.image == true) {
58
59
  const profileImage = await program.modules.data.file.downloadBuffer(result.profileImage,process.env.dbName);
@@ -129,6 +130,6 @@ module.exports = async function(db,collection,query,one = false,array) {
129
130
  }
130
131
 
131
132
  // Execute the main function
132
- await main().catch(console.error);
133
+ return await main().catch(console.error);
133
134
 
134
135
  }
@@ -1,10 +1,12 @@
1
- module.exports = async function(program, url, body) {
1
+ module.exports = async function(program, url, body,headers) {
2
2
  console.log(`Fetch Post`);
3
3
  // Register websocket url
4
4
  try {
5
- const headers = {
5
+ if (headers == undefined) {
6
+ headers = {
6
7
  accept: 'application/json',
7
8
  'content-type': 'application/json'
9
+ }
8
10
  };
9
11
 
10
12
  let theOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfast",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "description": "WebFast! Bot Application, including TON mini-apps for makign it easy and fast to build ini-apps",
5
5
  "main": "index.js",
6
6
  "repository": {