Skip to content

Commit

Permalink
configurable server url
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Mar 28, 2023
1 parent 583b875 commit 2da5b84
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/example_game_lazy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
JORNET_SECRET: ${{ secrets.JORNET_SECRET }}
BACKPACK_GAME_EXAMPLE_USERNAME: ""
BACKPACK_GAME_EXAMPLE_PASSWORD: ""
BACKPACK_SERVER_BASE_URL: ${{ secrets.BACKPACK_SERVER_BASE_URL }}
run: |
touch .env
cargo build --bin ${{ env.binary }} --profile wasm-release --target wasm32-unknown-unknown
Expand Down
3 changes: 2 additions & 1 deletion crates/example_game_lazy/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BACKPACK_GAME_EXAMPLE_USERNAME="yourname@example.com"
BACKPACK_GAME_EXAMPLE_PASSWORD=""
CHEAT="false"
JORNET_ID="jornet leaderboard id"
JORNET_SECRET="jornet leaderboard secret"
JORNET_SECRET="jornet leaderboard secret"
BACKPACK_SERVER_BASE_URL="127.0.0.1:8080"
8 changes: 4 additions & 4 deletions crates/example_game_lazy/src/game/scoreboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ impl Default for LeaderboardScreen {

impl Plugin for ScoreboardPlugin {
fn build(&self, app: &mut App) {
let jornet_id = dotenv!("JORNET_ID");
let jornet_secret = dotenv!("JORNET_SECRET");

app.add_state::<LeaderboardScreen>();
app.add_plugin(JornetPlugin::with_leaderboard(
dotenv!("JORNET_ID"),
dotenv!("JORNET_SECRET"),
));
app.add_plugin(JornetPlugin::with_leaderboard(jornet_id, jornet_secret));
app.add_startup_system(leaderboard_setup);
app.add_systems(
(ui_leaderboard, refresh_leaderboard).in_set(OnUpdate(LeaderboardScreen::Show)),
Expand Down
11 changes: 8 additions & 3 deletions crates/example_game_lazy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() {
drop(dotenvy::dotenv());
let email = dotenv!("BACKPACK_GAME_EXAMPLE_USERNAME");
let password = dotenv!("BACKPACK_GAME_EXAMPLE_PASSWORD");
let host = dotenv!("BACKPACK_SERVER_BASE_URL");
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
Expand All @@ -28,11 +29,15 @@ fn main() {
password: password.to_string(),
sign_in: password.is_empty(),
})
.add_plugin(AuthPlugin)
.add_plugin(AuthPlugin {
host: host.to_string(),
})
.run();
}

struct AuthPlugin;
struct AuthPlugin {
pub host: String,
}

#[derive(Resource, Debug)]
struct AuthData {
Expand Down Expand Up @@ -87,7 +92,7 @@ impl Plugin for AuthPlugin {
app.add_state::<PopupSignupSuccess>();
app.add_system(ui_signup_successful.in_set(OnUpdate(PopupSignupSuccess::Shown)));
app.init_resource::<AuthInput>();
app.insert_resource(BackpackCom::new("http://127.0.0.1:8080/api/v1".into()));
app.insert_resource(BackpackCom::new(self.host.clone() + "/api/v1".into()));
app.init_resource::<BackpackItems>();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"query": "\nUPDATE users_items SET amount = amount + $1\n WHERE user_id = $2 AND item_id = $3\n RETURNING amount\n ",
"query": "\n INSERT INTO users_email_password (email, password_hash, is_verified, user_id) VALUES ($1, $2, $3, $4)\n RETURNING id\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "amount",
"name": "id",
"type_info": "Int4"
}
],
"parameters": {
"Left": [
"Int4",
"Int4",
"Varchar",
"Text",
"Bool",
"Int4"
]
},
"nullable": [
false
]
},
"hash": "2b5bb2937da51c6ac3b1ff27a87e3a6377a778250f5d76de8d85fb5605521624"
"hash": "2144a74280e1ccb6cb3b3576144e5c5ee4d5d8268c3828b38d1e040199279ac8"
}

0 comments on commit 2da5b84

Please sign in to comment.