Skip to content

Make crate idiomatic, production-ready, and easy to use#11

Merged
kacy merged 3 commits intomasterfrom
refactor/idiomatic-production-ready
Jan 30, 2026
Merged

Make crate idiomatic, production-ready, and easy to use#11
kacy merged 3 commits intomasterfrom
refactor/idiomatic-production-ready

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Jan 30, 2026

Summary

Bumps version to 0.3.0 with the following changes:

  • Unified error type: Replace LogoutError and DbError with a single thiserror-derived Error enum (Config, Request, Serialization, Jwt, AuthRequired, Api)
  • Fallible constructor: Supabase::new() returns Result, validating that url and api_key are present
  • Typed auth responses: Auth methods return AuthResponse or EmptyResponse instead of raw reqwest::Response, with automatic non-2xx → Error::Api conversion
  • Header deduplication: Private auth_post() helper eliminates repeated header setup across 9 auth methods
  • DB error handling: execute() checks HTTP status and returns Error::Api for non-2xx; new execute_and_parse::<T>() for automatic JSON deserialization
  • Dependency cleanup: Remove unused time, move tokio to dev-deps, add thiserror = "2"
  • Ergonomic re-exports: Error, AuthResponse, Claims, QueryBuilder available at crate root
  • Documentation: Crate-level doc comment with quick start example; crates.io keywords/categories
  • #[must_use] on QueryBuilder to warn if .execute() is forgotten
  • Version bump from 0.2.0 → 0.3.0

Breaking changes

Change Migration
Supabase::new() returns Result Add ? or .unwrap()
Auth methods return AuthResponse/EmptyResponse Access fields directly
logout() returns single Result Remove nested match
DbError removed Use supabase_rust::Error
LogoutError removed Use Error::AuthRequired
tokio moved to dev-deps Users provide their own async runtime

Test plan

  • cargo build --lib compiles cleanly
  • cargo test — all 27 tests pass
  • cargo doc --no-deps — docs generate without warnings

kacy added 3 commits January 30, 2026 08:32
- Add unified Error type with thiserror, removing LogoutError and DbError
- Make Supabase::new() fallible, validating url and api_key are present
- Add typed AuthResponse/EmptyResponse structs for auth endpoints
- Deduplicate auth headers with private auth_post() helper
- Add API error handling (non-2xx returns Error::Api) in auth and db
- Add execute_and_parse<T>() convenience method on QueryBuilder
- Add #[must_use] on QueryBuilder
- Move tokio to dev-dependencies, remove unused time dependency
- Re-export key types (Error, AuthResponse, Claims, QueryBuilder)
- Add crate-level documentation with quick start example
- Add crates.io metadata (keywords, categories)
The CI environment has SUPABASE_URL and SUPABASE_API_KEY set, so tests
that assert new(None, ...) fails were passing due to env var fallback.
Temporarily remove the env vars in those tests and restore afterward.
@kacy kacy merged commit 1b14d31 into master Jan 30, 2026
1 check passed
kacy added a commit that referenced this pull request Jan 30, 2026
Make crate idiomatic, production-ready, and easy to use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant