Skip to content

Commit

Permalink
chore: comply with clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jflessau committed Dec 22, 2023
1 parent 438da03 commit 3861296
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/src/handler/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn walk(
fn grid_size(field_amount: usize) -> Result<usize> {
let grid_size = (field_amount as f32).sqrt();

if !(2..10).into_iter().any(|v| v as f32 == grid_size) {
if !(2..10).any(|v| v as f32 == grid_size) {
return Err(Error::InternalServer);
}

Expand Down
4 changes: 2 additions & 2 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ async fn main() {

tokio::select!(
_ = server::serve(pool.clone(), receiver.clone()) => {
tracing::error!("serfer::serve shut down"); return;
tracing::error!("serfer::serve shut down");
},
_ = pg_listen::listen(&pool, sender) => {
tracing::error!("pg_listener::listen shut down"); return;
tracing::error!("pg_listener::listen shut down");
}
);
}
10 changes: 9 additions & 1 deletion api/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub async fn serve(pool: PgPool, receiver: Receiver<HashMap<Uuid, DateTime<Utc>>
Method::POST,
Method::DELETE,
Method::PATCH,
Method::OPTIONS,
])
.allow_origin(Origin::list(vec![env::var("CORS_ALLOWED_ORIGIN")
.expect("CORS_ALLOWED_ORIGIN not set")
Expand Down Expand Up @@ -101,7 +102,14 @@ pub async fn serve(pool: PgPool, receiver: Receiver<HashMap<Uuid, DateTime<Utc>>
.layer(middleware_stack)
.layer(Extension(pool));

let addr = SocketAddr::from(([0, 0, 0, 0], port));
let environment = env::var("ENVIRONMENT").expect("ENVIRONMENT not set");

let addr = if environment == "production" {
SocketAddr::from(([0, 0, 0, 0], port))
} else {
SocketAddr::from(([127, 0, 0, 1], port))
};

tracing::info!("listening on {}", addr);

axum::Server::bind(&addr)
Expand Down
2 changes: 1 addition & 1 deletion web/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Home from './routes/Home.svelte';
import Game from './routes/Game.svelte';
import CreateTemplate from './routes/CreateTemplate.svelte';
import Snackbar from './components/Sackbar.svelte';
import Snackbar from './components/Snackbar.svelte';
import { Router, Route } from 'svelte-routing';
import { ApiClient } from './api.svelte';
import { AuthStatus, authStore } from './store.svelte';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" context="module">
import { get } from 'svelte/store';
import { NotificationLevel, notificationsStore } from './../store.svelte';
import { NotificationLevel, notificationsStore } from '../store.svelte';
export function createNotification(text: string) {
let notificationsData = get(notificationsStore);
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/Game.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Button from './../components/Button.svelte';
import { Circle } from 'svelte-loading-spinners';
import { Confetti } from 'svelte-confetti';
import { createNotification, toggleNotifications } from './../components/Sackbar.svelte';
import { createNotification, toggleNotifications } from '../components/Snackbar.svelte';
import { onMount } from 'svelte';
import { apiWsUrl, ApiClient } from './../api.svelte';
import { notificationsStore } from './../store.svelte';
Expand Down

0 comments on commit 3861296

Please sign in to comment.