File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change 11/** Services */
2- import { Server } from "../config"
2+ import { useSocketURL } from "../config"
33
44/** Store */
55import { useAppStore } from "@/store/app"
@@ -9,7 +9,7 @@ export let socket = null
99export const init = ( ) => {
1010 const appStore = useAppStore ( )
1111
12- socket = new WebSocket ( Server . WSS )
12+ socket = new WebSocket ( useSocketURL ( ) )
1313
1414 socket . addEventListener ( "open" , ( e ) => {
1515 /** Head Subscription */
Original file line number Diff line number Diff line change 1+ /** Services */
2+ import { useServerURL } from "@/services/config"
3+
4+ export const fetchHistogram = async ( { table, func, period } ) => {
5+ try {
6+ const url = new URL ( `${ useServerURL ( ) } /stats/histogram/${ table } /${ func } /${ period } ` )
7+
8+ const data = await useFetch ( url . href )
9+ return data
10+ } catch ( error ) {
11+ console . error ( error )
12+ }
13+ }
14+
15+ export const fetchSummary = async ( { table, func } ) => {
16+ try {
17+ const url = new URL ( `${ useServerURL ( ) } /stats/summary/${ table } /${ func } ` )
18+
19+ const data = await useFetch ( url . href )
20+ return data
21+ } catch ( error ) {
22+ console . error ( error )
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ export const Server = {
44 mocha : "https://api-mocha-4.celenium.io/v1" ,
55 dev : "https://api-dev.celenium.io/v1" ,
66 } ,
7- WSS : "wss://api-dev.celenium.io/v1/ws" ,
7+ WSS : {
8+ mainnet : "wss://api.celenium.io/v1/ws" ,
9+ mocha : "wss://api-dev.celenium.io/v1/ws" ,
10+ dev : "wss://api-dev.celenium.io/v1/ws" ,
11+ } ,
812}
913
1014export const useServerURL = ( ) => {
@@ -24,3 +28,21 @@ export const useServerURL = () => {
2428 return Server . API . dev
2529 }
2630}
31+
32+ export const useSocketURL = ( ) => {
33+ const requestURL = useRequestURL ( )
34+
35+ switch ( requestURL . hostname ) {
36+ case "celenium.io" :
37+ return Server . WSS . mainnet
38+
39+ case "mocha-4.celenium.io" :
40+ return Server . WSS . mocha
41+
42+ case "dev.celenium.io" :
43+ return Server . WSS . dev
44+
45+ default :
46+ return Server . WSS . dev
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments