Add holesail key section along with holesail tutorial and easy share tutorial so folks can share easy on discord
This commit is contained in:
@ -4,7 +4,7 @@ import { checkConnectionStatus, checkGeyserStatus, checkSftpStatus } from './sta
|
||||
import { apiRequest } from './api.js';
|
||||
|
||||
const clients = new Map();
|
||||
const staticEndpoints = ['log', 'website', 'map', 'my-link-cache', 'my-geyser-cache', 'my-sftp-cache', 'my-link', 'my-geyser-link', 'my-sftp'];
|
||||
const staticEndpoints = ['log', 'website', 'map', 'my-link-cache', 'my-geyser-cache', 'my-sftp-cache', 'my-link', 'my-geyser-link', 'my-sftp', 'holesail-hashes'];
|
||||
const dynamicEndpoints = ['hello', 'time', 'mod-list'];
|
||||
|
||||
// Helper function to start Docker stats interval
|
||||
@ -94,6 +94,44 @@ async function fetchAndSendUpdate(ws, endpoint, client, docker) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (endpoint === 'holesail-hashes' && client.cache['holesail-hashes']) {
|
||||
ws.send(JSON.stringify({ type: endpoint, data: client.cache['holesail-hashes'] }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (endpoint === 'holesail-hashes') {
|
||||
try {
|
||||
const [hashResponse, geyserHashResponse, sftpHashResponse] = await Promise.all([
|
||||
apiRequest('/my-hash', client.apiKey),
|
||||
apiRequest('/my-geyser-hash', client.apiKey),
|
||||
apiRequest('/my-sftp-hash', client.apiKey)
|
||||
]);
|
||||
|
||||
const response = {
|
||||
myHash: hashResponse.success ? hashResponse.message : null,
|
||||
geyserHash: geyserHashResponse.success ? geyserHashResponse.message : null,
|
||||
sftpHash: sftpHashResponse.success ? sftpHashResponse.message : null,
|
||||
errors: []
|
||||
};
|
||||
|
||||
if (!hashResponse.success) response.errors.push(`my-hash: ${hashResponse.message || 'Failed to fetch'}`);
|
||||
if (!geyserHashResponse.success) response.errors.push(`my-geyser-hash: ${geyserHashResponse.message || 'Failed to fetch'}`);
|
||||
if (!sftpHashResponse.success) response.errors.push(`my-sftp-hash: ${sftpHashResponse.message || 'Failed to fetch'}`);
|
||||
|
||||
client.cache['holesail-hashes'] = response;
|
||||
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
ws.send(JSON.stringify({ type: endpoint, data: response }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching holesail-hashes for ${client.user}:`, error.message);
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
ws.send(JSON.stringify({ type: endpoint, error: `Failed to fetch holesail hashes: ${error.message}` }));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await apiRequest(`/${endpoint}`, client.apiKey);
|
||||
if (!response.error) {
|
||||
if (endpoint === 'time') client.cache['time'] = response;
|
||||
@ -174,7 +212,6 @@ async function fetchAndSendUpdate(ws, endpoint, client, docker) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function manageStatusChecks(ws, client, user, docker) {
|
||||
try {
|
||||
const container = docker.getContainer(user);
|
||||
@ -402,7 +439,7 @@ export function handleWebSocket(ws, req, docker) {
|
||||
client.intervals.push(setInterval(async () => {
|
||||
try {
|
||||
for (const endpoint of staticEndpoints) {
|
||||
if (client.subscriptions.has(endpoint)) {
|
||||
if (client.subscriptions.has(endpoint) && endpoint !== 'holesail-hashes') {
|
||||
await fetchAndSendUpdate(ws, endpoint, client, docker);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user