feat: disable stats endpoint if enableMetrics is false

This commit is contained in:
SamTV12345 2025-07-27 21:54:24 +02:00 committed by SamTV12345
parent 45a906e19d
commit 40884fa96b
11 changed files with 462 additions and 647 deletions

View file

@ -9,22 +9,29 @@ export const ShoutPage = ()=>{
const [message, setMessage] = useState<string>("");
const [sticky, setSticky] = useState<boolean>(false);
const socket = useStore(state => state.settingsSocket);
const pluginSocket = useStore(state => state.pluginsSocket);
const [shouts, setShouts] = useState<ShoutType[]>([]);
useEffect(() => {
fetch('/stats')
.then(response => response.json())
.then(data => setTotalUsers(data.totalUsers));
}, []);
useEffect(() => {
if(socket) {
if(socket && pluginSocket) {
console.log('Socket connected', socket.id);
socket.on('shout', (shout) => {
setShouts([...shouts, shout])
})
pluginSocket.on('results:stats', (statData) => {
console.log('Shoutdata', statData);
setTotalUsers(statData.totalUsers);
})
}
}, [socket, shouts])
}, [socket, shouts, pluginSocket])
useEffect(() => {
if (pluginSocket) {
pluginSocket.emit('getStats', {});
}
}, [pluginSocket]);
const sendMessage = () => {
socket?.emit('shout', {

View file

@ -28,10 +28,6 @@ export default defineConfig({
'/admin-auth/': {
target: 'http://localhost:9001',
changeOrigin: true,
},
'/stats': {
target: 'http://localhost:9001',
changeOrigin: true,
}
}
}