main-site/src/routes/services/+page.server.ts

27 lines
519 B
TypeScript

import { io } from 'socket.io-client';
import * as fs from 'fs';
export async function load() {
const credFile = './credentials.json';
const socket = io('https://status.neshweb.net/');
let token = '';
socket.on('connect', () => {
socket.emit(
'login',
{ username: process.env.KUMA_USERNAME, password: process.env.KUMA_PASSWORD, token: '' },
(res) => {
token = res.token;
}
);
});
while (token == '') {
await new Promise((resolve) => setTimeout(resolve, 10));
}
return {
token
};
}