Skip to content

Commit

Permalink
moved node api url to store
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMatthew committed Mar 19, 2021
1 parent 35dc2e5 commit 6478820
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/op-arcade-sdk/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export const isTournament = writable(false);
export const tourneyStore = getTourneyStore();
export const authStore = getAuthStore();

export const NODE_API_URL = writable({
dev: "http://127.0.0.1:3001/oparcade/api",
prod: "http://op-arcade-dev.herokuapp.com/oparcade/api"
})

export async function useServers(options) {
let auth_provider = await get(authStore).useServer(options.auth_server);
let tourney_provider = await get(tourneyStore).useServer(options.tourney_server, auth_provider);
Expand Down
11 changes: 5 additions & 6 deletions packages/op-arcade-sdk/src/tourney/nakama.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import CONSTANTS from '../constants.js'
import * as nakamajs from '@heroiclabs/nakama-js';

// const axios = require('axios')
import {get} from 'svelte/store'
import {isProd, NODE_API_URL} from '../stores'
import axios from 'axios'

const TEST_ID = "test_id"
Expand Down Expand Up @@ -95,11 +96,9 @@ class NakamaTourneyProvider {
}
}

const dev = 'http://127.0.0.1:3001/oparcade/api/tournaments/post-score'
const prod = 'http://op-arcade-dev.herokuapp.com/oparcade/api/tournaments/post-score'
const isDevelopment = false
const requestURL = isDevelopment ? dev : prod
const res = await axios.post(requestURL, args, config)
const {prod, dev} = get(NODE_API_URL)
const requestURL = get(isProd) ? prod : dev
const res = await axios.post(`${requestURL}/tournaments/post-score`, args, config)
return res
} catch (e) {
console.error("postScore failed [" + e.status + ":" + e.statusText + "]");
Expand Down

0 comments on commit 6478820

Please sign in to comment.