feat: refactor Python SDK and enhance API error reporting

- Relocated Python SDK to `sdk/python/datastack` with new auto-configuration support via `config.datastack.py`
- Updated SDK installation and usage documentation
- Enhanced `/api/events` response format to include specific error codes for revoked and rotated credentials
- Updated SDK dashboard snippet generator to support new configuration pattern
This commit is contained in:
Team Dark Devil committed 2026-11-18 02:23:01 +06:00
1 parent 367dd819f8
commit 0c2e49cd47
18 files changed
+2288 -249

No files matched your search

+3 -1
View File
@@ -252,7 +252,7 @@ const io = new Server(server, {
cors: { origin: '*', methods: ['GET', 'POST'] },
});
// Health check endpoint with activeSockets count
// Health check endpoint with activeSockets count and runtime capabilities
app.get('/health', (_req, res) => {
res.json({
status: 'online',
@@ -260,6 +260,8 @@ app.get('/health', (_req, res) => {
port: PORT,
activeSockets: io.engine ? io.engine.clientsCount : 0,
bufferSize: bufferQueue.length,
maxEventsPerSec: runtimeConfig.maxEventsPerSec,
maxPayloadSizeBytes: runtimeConfig.maxPayloadSizeBytes,
uptime: process.uptime(),
});
});
+41
View File
@@ -307,6 +307,47 @@ function setupSocketHandlers(io, bufferQueue, worker, options = {}) {
}
}
});
// Heartbeat & Reconnection Verification Event
socket.on("ping_verify", async (_payload, callback) => {
try {
const dbCheck = await verifyClientInDb(
clientId,
socket.data.token,
true,
);
if (!dbCheck.allowed) {
if (callback) {
callback({
success: false,
status: "REVOKED",
error: dbCheck.reason || "CLIENT_REVOKED",
});
}
socket.disconnect(true);
return;
}
const config = getRuntimeConfig();
if (callback) {
callback({
success: true,
status: "VERIFIED",
clientId,
rateLimit: dbCheck.rateLimit || socket.data.rateLimit || 100,
maxPayloadSizeBytes: config.maxPayloadSizeBytes,
serverTime: new Date().toISOString(),
});
}
} catch (err) {
if (callback) {
callback({
success: false,
status: "ERROR",
error: err.message,
});
}
}
});
});
}