webfast 0.1.83 → 0.1.85
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 +31 -9
- package/index.js +1 -1
- package/modules/data/mongo/find.js +57 -55
- package/modules/express/init.js +1 -1
- package/package.json +6 -3
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.
|
@@ -97,6 +97,18 @@ web.fast = {
|
|
97
97
|
list : function(data) {
|
98
98
|
console.log(`Processing List`);
|
99
99
|
}
|
100
|
+
},
|
101
|
+
telegram : function(action){
|
102
|
+
try {
|
103
|
+
const telegram = window.Telegram;
|
104
|
+
const actionFunction = telegram[action];
|
105
|
+
console.log(`TELEGRAM`,action);
|
106
|
+
return actionFunction;
|
107
|
+
} catch (err) {
|
108
|
+
//console.error(Err);
|
109
|
+
console.error(`NO TELEGRAM`,action);
|
110
|
+
return false;
|
111
|
+
}
|
100
112
|
}
|
101
113
|
}
|
102
114
|
// Connect to the Socket.IO server
|
@@ -127,6 +139,16 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
127
139
|
web.fast.que.state = true;
|
128
140
|
|
129
141
|
//alert(web.fast.tools.isMobile);
|
142
|
+
var generateRandomId = async function(length) {
|
143
|
+
var result = '';
|
144
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
145
|
+
var charactersLength = characters.length;
|
146
|
+
for (var i = 0; i < length; i++) {
|
147
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
148
|
+
}
|
149
|
+
return result;
|
150
|
+
};
|
151
|
+
|
130
152
|
function arraySend() {
|
131
153
|
try {
|
132
154
|
if (web.fast.user != undefined && web.fast.inial == undefined || window.Telegram.WebApp.initData == `` && web.fast.inial == undefined) {
|
@@ -134,16 +156,8 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
134
156
|
jQuery(`[webfast-get]`).each(async function(){
|
135
157
|
const type = jQuery(this).attr(`webfast-get`);
|
136
158
|
let id = jQuery(this).attr(`id`);
|
159
|
+
console.log(`THE GET`);
|
137
160
|
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
161
|
id = await generateRandomId(8); // Generate a random ID of length 8
|
148
162
|
}
|
149
163
|
arraySend.push({
|
@@ -183,6 +197,7 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
183
197
|
// We have user data
|
184
198
|
console.log(`Set User Data`);
|
185
199
|
web.fast.user = json;
|
200
|
+
|
186
201
|
// Now go Through to set all data
|
187
202
|
// Get all webfast client
|
188
203
|
jQuery(`[webfast-client]`).each(function(){
|
@@ -224,6 +239,13 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
224
239
|
|
225
240
|
web.fast.que.state = Date.now();
|
226
241
|
web.fast.receive(`socket`,event.data); // Placeholder for processing response
|
242
|
+
jQuery(document).ready(function(){
|
243
|
+
try {
|
244
|
+
web.fast.tools.on.connect();
|
245
|
+
} catch (err) {
|
246
|
+
console.error(`error getting connect data`);
|
247
|
+
}
|
248
|
+
})
|
227
249
|
} catch (err) {
|
228
250
|
console.error(`Error Receiving`);
|
229
251
|
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 {
|
@@ -67,65 +67,67 @@ module.exports = async function(db,collection,query,one = false,array) {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
// Check if profile image to get it from db
|
70
|
-
if (result
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
70
|
+
if (result != undefined) {
|
71
|
+
if (result.profileImage != undefined && array.image == true) {
|
72
|
+
const profileImage = await program.modules.data.file.downloadBuffer(result.profileImage,process.env.dbName);
|
73
|
+
|
74
|
+
// Set in dynamic routing for serving
|
75
|
+
let sizeMeta = {};
|
76
|
+
let other = {}
|
77
|
+
for (let pi in profileImage) {
|
78
|
+
// Profile image
|
79
|
+
const theImage = profileImage[pi];
|
80
|
+
|
81
|
+
// Get the meta
|
82
|
+
const imageMeta = theImage.metadata;
|
83
|
+
|
84
|
+
// Sizes
|
85
|
+
const size = imageMeta.size;
|
86
|
+
|
87
|
+
const sizeKey = `${size.width}x${size.height}`;
|
88
|
+
const setUUID = program.uuid.v4();
|
89
|
+
sizeMeta[setUUID] = {
|
90
|
+
buffer : theImage.buffer,
|
91
|
+
meta : imageMeta
|
92
|
+
}
|
93
|
+
console.log(`The Size Meta`);
|
91
94
|
}
|
92
|
-
console.log(`The Size Meta`);
|
93
|
-
}
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
96
|
+
// Now we have sizes thingy so create a route for this specific uuid
|
97
|
+
const dynamicLink = `/dynamic/${result.profileImage}/list`;
|
98
|
+
result.imageList = `${process.env.url}${dynamicLink.slice(1)}`;
|
99
|
+
result.images = sizeMeta;
|
100
|
+
|
101
|
+
const routeCheck = await routeExists(dynamicLink);
|
102
|
+
if (!routeCheck) {
|
103
|
+
program.express.app.get(dynamicLink, async (req, res) => {
|
104
|
+
// Requesting image
|
105
|
+
console.log(`Requesting dynamic link`);
|
106
|
+
// Send buffer image as image
|
107
|
+
// Set content type header to indicate that you're sending an image
|
108
|
+
res.setHeader('Content-Type', 'application/json');
|
109
|
+
|
110
|
+
// Send the image buffer as the response body
|
111
|
+
for (let sizeKey in sizeMeta) {
|
112
|
+
const item = sizeMeta[sizeKey];
|
113
|
+
other[sizeKey] = item.meta;
|
114
|
+
|
115
|
+
// Create dynamic url for this on
|
116
|
+
const imageDynamicPath = `/dynamic/${sizeKey}.${item.meta.type}`;
|
117
|
+
const imageLinkURL = `https://${process.env.url}${imageDynamicPath.slice(1)}`
|
118
|
+
//other[sizeKey].link = imageLinkURL;
|
119
|
+
|
120
|
+
// generate dynamic url
|
121
|
+
|
122
|
+
}
|
120
123
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
console.log(`Profile Image`);
|
124
|
+
res.send(JSON.stringify(other, null, 2));
|
125
|
+
});
|
126
|
+
}
|
127
|
+
console.log(`Profile Image`);
|
127
128
|
|
128
|
-
|
129
|
+
// generate paths
|
130
|
+
}
|
129
131
|
}
|
130
132
|
|
131
133
|
if (callback != undefined) {
|
package/modules/express/init.js
CHANGED
@@ -392,7 +392,7 @@ module.exports = async function (program) {
|
|
392
392
|
// Check if function is running in program modules that you can add in the init scirpt when using remote
|
393
393
|
if (program.express.process != undefined) {
|
394
394
|
try {
|
395
|
-
let resp = await program.express.process[split[0]][split[1]][split[2]](program,ws,json,data,path,clientId);
|
395
|
+
let resp = await program.express.process[split[0]][split[1]][split[2]](program,ws,json,data,path,clientId,ws);
|
396
396
|
if (resp != false) {
|
397
397
|
ws.send(JSON.stringify(resp));
|
398
398
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webfast",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.85",
|
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": {
|
@@ -25,14 +25,17 @@
|
|
25
25
|
"generator",
|
26
26
|
"mini-app",
|
27
27
|
"express",
|
28
|
-
"
|
28
|
+
"bot",
|
29
29
|
"famework",
|
30
30
|
"ejs",
|
31
31
|
"javascript",
|
32
32
|
"jquery",
|
33
33
|
"webfast",
|
34
34
|
"dynamic",
|
35
|
-
"model"
|
35
|
+
"model",
|
36
|
+
"mini app",
|
37
|
+
"webflow",
|
38
|
+
"lowcode"
|
36
39
|
],
|
37
40
|
"author": "Kai Gartner",
|
38
41
|
"license": "ISC",
|