Skip to content

Commit

Permalink
make all api operations use relative paths
Browse files Browse the repository at this point in the history
Signed-off-by: Daan Poron <[email protected]>
  • Loading branch information
daanporon committed Sep 12, 2023
1 parent fec8c3e commit 3968a3f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions client/src/state/redux/auth/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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 }));
})
Expand All @@ -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(
Expand All @@ -67,7 +67,7 @@ const register = user => dispatch =>
});

const userlist = () => dispatch =>
get('/api/userlist')
get('api/userlist')
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -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(
Expand All @@ -113,7 +113,7 @@ const unregister = user => dispatch =>
});

const logout = () => dispatch =>
post('/auth/logout', {})
post('auth/logout', {})
.then(resp => {
console.log(resp);
Auth.deauthenticateUser();
Expand Down
20 changes: 10 additions & 10 deletions client/src/state/redux/charts/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
28 changes: 14 additions & 14 deletions client/src/state/redux/tables/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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}));
Expand All @@ -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) {
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit 3968a3f

Please sign in to comment.