Skip to content

Commit

Permalink
refactor: examples split into own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
roberts-pumpurs committed Oct 20, 2024
1 parent be5c3bd commit c2f81be
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 141 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod_module_files = "allow"
supabase-mock = { path = "crates/supabase-mock" }
supabase-auth = { path = "crates/supabase-auth" }
postgrest-error = { path = "crates/postgrest-error" }
supabase-realtime = { path = "crates/supabase-realtime" }

# Async
futures-concurrency = "7.4"
Expand Down
25 changes: 25 additions & 0 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "examples"
version = "0.1.0"
edition = "2021"

[dependencies]
clap.workspace = true
color-eyre.workspace = true
supabase-realtime.workspace = true
supabase-auth.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
simd-json.workspace = true

[lints]
workspace = true

[[bin]]
name = "realtime-example"
path = "src/realtime_example.rs"

[[bin]]
name = "auth_example"
path = "src/auth_example.rs"
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::time::Duration;
use core::time::Duration;

use clap::Parser;
use futures::StreamExt;
use supabase_auth::futures::StreamExt as _;
use supabase_auth::url;
use tracing_subscriber::EnvFilter;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -38,8 +39,8 @@ async fn main() {
EnvFilter::builder()
.from_env()
.unwrap()
.add_directive(format!("supabase_auth=debug").parse().unwrap())
.add_directive(format!("auth_example=debug").parse().unwrap()),
.add_directive("supabase_auth=debug".to_owned().parse().unwrap())
.add_directive("auth_example=debug".to_owned().parse().unwrap()),
)
.init();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::borrow::Cow;
use std::time::Duration;
use core::time::Duration;

use clap::Parser;
use futures::StreamExt;
use supabase_auth::redact::Secret;
use supabase_realtime::message::{phx_join, ProtocolMessage};
use tokio_stream::wrappers::ReceiverStream;
use supabase_auth::url;
use supabase_realtime::futures::StreamExt as _;
use supabase_realtime::message::phx_join;
use tracing_subscriber::EnvFilter;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -40,9 +38,9 @@ async fn main() {
EnvFilter::builder()
.from_env()
.unwrap()
.add_directive(format!("supabase_auth=info").parse().unwrap())
.add_directive(format!("supabase_realtime=info").parse().unwrap())
.add_directive(format!("example1=info").parse().unwrap()),
.add_directive("supabase_auth=info".to_owned().parse().unwrap())
.add_directive("supabase_realtime=info".to_owned().parse().unwrap())
.add_directive("example1=info".to_owned().parse().unwrap()),
)
.init();
color_eyre::install().unwrap();
Expand Down Expand Up @@ -70,12 +68,10 @@ async fn main() {
self_item: false,
ack: false,
},
presence: phx_join::PresenceConfig {
key: "".to_string(),
},
presence: phx_join::PresenceConfig { key: String::new() },
postgres_changes: vec![phx_join::PostgrsChanges {
event: phx_join::PostgresChangetEvent::All,
schema: "public".to_string(),
schema: "public".to_owned(),
table: args.table,
filter: args.filter,
}],
Expand Down
1 change: 0 additions & 1 deletion crates/supabase-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use simd_json::json;
use thiserror::Error;
use tokio::task::JoinSet;
pub use {futures, redact, url};

pub const SUPABASE_KEY: &str = "apikey";

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down
4 changes: 2 additions & 2 deletions crates/supabase-realtime/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::future::Future;
use std::sync::Arc;
use alloc::sync::Arc;
use core::future::Future;

use bytes::Bytes;
use fastwebsockets::FragmentCollector;
Expand Down
4 changes: 4 additions & 0 deletions crates/supabase-realtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
extern crate alloc;

mod connection;
mod error;
pub mod message;
pub mod realtime;

pub use {futures, supabase_auth, url};
Loading

0 comments on commit c2f81be

Please sign in to comment.