refract: cleanup server call constants

This commit is contained in:
cv
2021-05-16 22:41:43 +02:00
parent b42710a972
commit 8162c622a6
8 changed files with 46 additions and 60 deletions
+5
View File
@@ -1,7 +1,12 @@
export const NODE_PORT = 4001;
export const EVENT_TABLE = 'event';
export const EVENTS_TABLE = 'events';
const calculateServer = () => {
return window.location.origin.replace(window.location.port, `${NODE_PORT}/`);
};
export const serverURL = calculateServer();
export const eventURL = serverURL + EVENT_TABLE;
export const eventsURL = serverURL + EVENTS_TABLE;
export const playbackURL = serverURL + 'playback';
+1 -4
View File
@@ -1,8 +1,5 @@
import axios from 'axios';
import { serverURL } from './apiConstants';
export const eventNamespace = 'event';
export const eventURL = serverURL + eventNamespace;
import { eventURL } from './apiConstants';
export const fetchEvent = async () => {
const res = await axios.get(eventURL);
+1 -10
View File
@@ -1,14 +1,5 @@
import axios from 'axios';
import { NODE_PORT } from '../api/apiConstants';
// get origin from URL
const serverURL = window.location.origin.replace(
window.location.port,
`${NODE_PORT}/`
);
export const eventsNamespace = 'events';
export const eventsURL = serverURL + eventsNamespace;
import { eventsURL } from '../api/apiConstants';
export const fetchAllEvents = async () => {
const res = await axios.get(eventsURL);
+1 -4
View File
@@ -1,8 +1,5 @@
import axios from 'axios';
import { serverURL } from '../api/apiConstants';
export const playbackNamespace = 'playback';
const playbackURL = serverURL + playbackNamespace;
import { playbackURL } from '../api/apiConstants';
export const getStart = async () => {
const res = await axios.get(playbackURL + '/start');
+1 -7
View File
@@ -1,12 +1,6 @@
import { createContext, useContext, useEffect, useState } from 'react';
import io from 'socket.io-client';
import { NODE_PORT } from '../api/apiConstants';
// get origin from URL
const serverURL = window.location.origin.replace(
window.location.port,
`${NODE_PORT}/`
);
import { serverURL } from 'app/api/apiConstants';
const SocketContext = createContext([[], () => {}]);