update lại thư mục cấu trúc mới của server nodejs và python

This commit is contained in:
Victor Phan
2026-07-21 09:13:52 +07:00
parent 7625bdd37b
commit 58b1dcd170
1555 changed files with 0 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
'use strict';
const _5_MINUTES = 5 * 60 * 1000;
class CallbacksMap extends Map {
/**
* @param ttl Time to live in milliseconds. Default is 5 minutes.
*/
set(key, value, ttl = _5_MINUTES) {
setTimeout(() => {
this.delete(key);
}, ttl);
return super.set(key, value);
}
}
const createContext = (apiType = 30, apiVersion = 671) => ({
API_TYPE: apiType,
API_VERSION: apiVersion,
uploadCallbacks: new CallbacksMap(),
options: {
selfListen: false,
checkUpdate: true,
logging: true,
polyfill: global.fetch,
},
secretKey: null,
});
function isContextSession(ctx) {
return !!ctx.secretKey;
}
const MAX_MESSAGES_PER_SEND = 50;
exports.MAX_MESSAGES_PER_SEND = MAX_MESSAGES_PER_SEND;
exports.createContext = createContext;
exports.isContextSession = isContextSession;