From 3968a3f27948451660a58c5d9c22956675a1babc Mon Sep 17 00:00:00 2001 From: Daan Poron Date: Tue, 12 Sep 2023 14:34:22 +0200 Subject: [PATCH] make all api operations use relative paths Signed-off-by: Daan Poron --- client/src/state/redux/auth/operations.js | 12 ++++----- client/src/state/redux/charts/operations.js | 20 +++++++-------- client/src/state/redux/tables/operations.js | 28 ++++++++++----------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/client/src/state/redux/auth/operations.js b/client/src/state/redux/auth/operations.js index 582198d38..09f1d0fde 100644 --- a/client/src/state/redux/auth/operations.js +++ b/client/src/state/redux/auth/operations.js @@ -18,7 +18,7 @@ import actions from '../charts/actions'; import Auth from '../../Auth'; const login = ({ user, password }, networkObj) => dispatch => - post('/auth/login', { user, password, network: networkObj }) + post('auth/login', { user, password, network: networkObj }) .then(resp => { Auth.authenticateUser(resp.token); dispatch(errorAction(null)); @@ -33,7 +33,7 @@ const login = ({ user, password }, networkObj) => dispatch => }); const network = () => dispatch => - get('/auth/networklist', {}) + get('auth/networklist', {}) .then(({ networkList }) => { dispatch(networkAction({ networks: networkList })); }) @@ -44,7 +44,7 @@ const network = () => dispatch => }); const register = user => dispatch => - post('/api/register', { ...user }) + post('api/register', { ...user }) .then(resp => { if (resp.status === 500) { dispatch( @@ -67,7 +67,7 @@ const register = user => dispatch => }); const userlist = () => dispatch => - get('/api/userlist') + get('api/userlist') .then(resp => { if (resp.status === 500) { dispatch( @@ -90,7 +90,7 @@ const userlist = () => dispatch => }); const unregister = user => dispatch => - post('/api/unregister', { ...user }) + post('api/unregister', { ...user }) .then(resp => { if (resp.status === 500) { dispatch( @@ -113,7 +113,7 @@ const unregister = user => dispatch => }); const logout = () => dispatch => - post('/auth/logout', {}) + post('auth/logout', {}) .then(resp => { console.log(resp); Auth.deauthenticateUser(); diff --git a/client/src/state/redux/charts/operations.js b/client/src/state/redux/charts/operations.js index 0beb7c5bd..51fcc327f 100644 --- a/client/src/state/redux/charts/operations.js +++ b/client/src/state/redux/charts/operations.js @@ -7,7 +7,7 @@ import { get } from '../../../services/request'; /* istanbul ignore next */ const blockPerHour = channelName => dispatch => - get(`/api/blocksByHour/${channelName}/1`) + get(`api/blocksByHour/${channelName}/1`) .then(resp => { if (resp.status === 500) { dispatch( @@ -27,7 +27,7 @@ const blockPerHour = channelName => dispatch => /* istanbul ignore next */ const blockPerMin = channelName => dispatch => - get(`/api/blocksByMinute/${channelName}/1`) + get(`api/blocksByMinute/${channelName}/1`) .then(resp => { if (resp.status === 500) { dispatch( @@ -47,7 +47,7 @@ const blockPerMin = channelName => dispatch => /* istanbul ignore next */ const changeChannel = channelName => dispatch => - get(`/api/changeChannel/${channelName}`) + get(`api/changeChannel/${channelName}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -67,7 +67,7 @@ const changeChannel = channelName => dispatch => /* istanbul ignore next */ const channel = () => dispatch => - get('/api/curChannel') + get('api/curChannel') .then(resp => { if (resp.status === 500) { dispatch( @@ -87,7 +87,7 @@ const channel = () => dispatch => /* istanbul ignore next */ const channelList = () => dispatch => - get('/api/channels') + get('api/channels') .then(resp => { if (resp.status === 500) { dispatch( @@ -107,7 +107,7 @@ const channelList = () => dispatch => /* istanbul ignore next */ const dashStats = channelName => dispatch => - get(`/api/status/${channelName}`) + get(`api/status/${channelName}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -127,7 +127,7 @@ const dashStats = channelName => dispatch => /* istanbul ignore next */ const blockActivity = channelName => dispatch => - get(`/api/blockActivity/${channelName}`) + get(`api/blockActivity/${channelName}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -154,7 +154,7 @@ const notification = notificationObj => dispatch => { /* istanbul ignore next */ const transactionByOrg = channelName => dispatch => - get(`/api/txByOrg/${channelName}`) + get(`api/txByOrg/${channelName}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -174,7 +174,7 @@ const transactionByOrg = channelName => dispatch => /* istanbul ignore next */ const transactionPerHour = channelName => dispatch => - get(`/api/txByHour/${channelName}/1`) + get(`api/txByHour/${channelName}/1`) .then(resp => { if (resp.status === 500) { dispatch( @@ -194,7 +194,7 @@ const transactionPerHour = channelName => dispatch => /* istanbul ignore next */ const transactionPerMin = channelName => dispatch => - get(`/api/txByMinute/${channelName}/1`) + get(`api/txByMinute/${channelName}/1`) .then(resp => { if (resp.status === 500) { dispatch( diff --git a/client/src/state/redux/tables/operations.js b/client/src/state/redux/tables/operations.js index 63114118f..8aaa329b3 100644 --- a/client/src/state/redux/tables/operations.js +++ b/client/src/state/redux/tables/operations.js @@ -7,7 +7,7 @@ import { get } from '../../../services/request'; /* istanbul ignore next */ const blockListSearch = (channel, query, pageParams) => dispatch => get( - `/api/blockAndTxList/${channel}/0?${query ? query : '' + `api/blockAndTxList/${channel}/0?${query ? query : '' }&page=${pageParams?.page || 1}&size=${pageParams?.size || 10}` ) .then(resp => { @@ -30,7 +30,7 @@ const blockListSearch = (channel, query, pageParams) => dispatch => /* istanbul ignore next */ const chaincodeList = channel => dispatch => - get(`/api/chaincode/${channel}`) + get(`api/chaincode/${channel}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -52,7 +52,7 @@ const chaincodeList = channel => dispatch => /* istanbul ignore next */ const channels = () => dispatch => - get('/api/channels/info') + get('api/channels/info') .then(resp => { if (resp.status === 500) { dispatch( @@ -72,7 +72,7 @@ const channels = () => dispatch => /* istanbul ignore next */ const peerList = channel => dispatch => - get(`/api/peersStatus/${channel}`) + get(`api/peersStatus/${channel}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -91,7 +91,7 @@ const peerList = channel => dispatch => }); const txnList = (channel, query) => dispatch => - get(`/api/fetchDataByTxnId/${channel}/${query}`) + get(`api/fetchDataByTxnId/${channel}/${query}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -111,7 +111,7 @@ const txnList = (channel, query) => dispatch => }); const blockSearch = (channel, query) => dispatch => - get(`/api/fetchDataByBlockNo/${channel}/${query}`) + get(`api/fetchDataByBlockNo/${channel}/${query}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -132,7 +132,7 @@ const blockSearch = (channel, query) => dispatch => /* istanbul ignore next */ const transaction = (channel, transactionId) => dispatch => - get(`/api/transaction/${channel}/${transactionId}`) + get(`api/transaction/${channel}/${transactionId}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -151,7 +151,7 @@ const transaction = (channel, transactionId) => dispatch => }); const transactionListSearch = (channel, query, pageParams) => dispatch => - get(`/api/txList/${channel}/0/0?${query?query:''}&page=${pageParams?.page||1}&size=${pageParams?.size||10}`) + get(`api/txList/${channel}/0/0?${query?query:''}&page=${pageParams?.page||1}&size=${pageParams?.size||10}`) .then(resp => { let params={page:pageParams?.page||1,size:pageParams?.size ||10} dispatch(actions.getTransactionListSearch({...resp,query,pageParams:params})); @@ -162,7 +162,7 @@ const transactionListSearch = (channel, query, pageParams) => dispatch => const blockRangeSearch = (channel, query1, query2) => dispatch => { dispatch(actions.getLoaded(false)); - get(`/api/fetchDataByBlockRange/${channel}/${query1}/${query2}`) + get(`api/fetchDataByBlockRange/${channel}/${query1}/${query2}`) .then(resp => { console.log('response-got', resp); if (resp.status === 500) { @@ -183,7 +183,7 @@ const blockRangeSearch = (channel, query1, query2) => dispatch => } /* istanbul ignore next */ const transactionList = (channel,params) => dispatch => - get(`/api/txList/${channel}/0/0/?page=${params.page}&size=${params.size}`) + get(`api/txList/${channel}/0/0/?page=${params.page}&size=${params.size}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -202,7 +202,7 @@ const transactionList = (channel,params) => dispatch => }); const chaincodeMetaData = (channel,query) => dispatch => - get(`/api/metadata/${channel}/${query}`) + get(`api/metadata/${channel}/${query}`) .then(resp => { if (resp.status === 500) { dispatch( @@ -219,13 +219,13 @@ const chaincodeMetaData = (channel,query) => dispatch => .catch(error => { console.error(error); }); - + export default { chaincodeList, channels, peerList, - txnList, - blockSearch, + txnList, + blockSearch, chaincodeMetaData, transaction, transactionList,