Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.x dev #279

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a0262d3
Drop `create-rspc-app`
oscartbeaumont Mar 17, 2024
d636266
Fix #260
oscartbeaumont Mar 17, 2024
45d3821
Upgrade workspace + Axum 0.7
oscartbeaumont Mar 17, 2024
dc8b8f6
:tada: Release 0.1.4
oscartbeaumont Mar 17, 2024
97ae909
Split out httpz stuff into dedicated crate
oscartbeaumont Mar 17, 2024
2ebaa76
Split out Tauri stuff into dedicated crate
oscartbeaumont Mar 17, 2024
a30b751
Drop `httpz` for Axum integration
oscartbeaumont Mar 17, 2024
8224801
Drop `rspc::Type` & most `rspc` features
oscartbeaumont Mar 17, 2024
55dbd4e
cleanup
oscartbeaumont Mar 17, 2024
d4721aa
Bring back Axum websocket support
oscartbeaumont Mar 17, 2024
e22d780
drop `cookies` from Axum integration
oscartbeaumont Mar 17, 2024
847ec21
rspc logo in Rust docs
oscartbeaumont Mar 17, 2024
a086620
Upgrade to Tanstack Query v5
oscartbeaumont Mar 17, 2024
20cf52f
Backport websocket reconnect fix + Fix Astro example
oscartbeaumont Mar 17, 2024
f696dba
:tada: Release 0.2.0
oscartbeaumont Mar 17, 2024
83ae855
Axum: Make the `handle_*` functions private
oscartbeaumont Mar 17, 2024
f9a5ecb
:tada: rspc-axum 0.1.1
oscartbeaumont Mar 17, 2024
ca44b5f
publish 0.2.0 npm packages
oscartbeaumont Mar 17, 2024
d58935e
Tauri v2 JS adapter
oscartbeaumont Apr 30, 2024
c57fa59
Optional Specta v2 support
oscartbeaumont May 1, 2024
f250409
properly support axum extractors
Brendonovich May 10, 2024
8f829bb
feat: add `useUtils` style fetch and prefetch
johann-crabnebula Jun 24, 2024
c7b8bc9
fix: update name to be `useUtils` instead
johann-crabnebula Jun 25, 2024
31f9f90
Merge pull request #288 from johann-crabnebula/feat/add-fetch-and-pre…
Brendonovich Jun 25, 2024
c5fccbd
Biome + flesh out useUtils (#289)
Brendonovich Jul 1, 2024
4c1fe37
update lockfile
oscartbeaumont Jul 1, 2024
6e1da5b
:tada: release 0.2.1 of JS packages
oscartbeaumont Jul 1, 2024
5e7c1ef
fix publint stuff + upgrade workspace
oscartbeaumont Jul 2, 2024
cff0b23
fix(@rspc/react): make sure type-only export gets stripped from .mjs …
jedwards1211 Jul 10, 2024
9e56e7f
:tada: Release 0.2.2 of JS packages
oscartbeaumont Jul 11, 2024
a389775
solid and react query packages
Brendonovich Jul 12, 2024
bbc5887
svelte client
Brendonovich Jul 12, 2024
3060313
fix tsc and add svelte
Brendonovich Jul 12, 2024
47b3ace
Merge branch 'v0.x' into query-packages
Brendonovich Jul 12, 2024
6eb129f
update docs
Brendonovich Jul 12, 2024
40fcc45
declaration maps
Brendonovich Jul 13, 2024
188900b
fix astro
Brendonovich Jul 13, 2024
0fa3816
Merge pull request #294 from oscartbeaumont/query-packages
Brendonovich Jul 13, 2024
9f26d64
:tada: Release clients 0.2.3
oscartbeaumont Jul 13, 2024
ddf8e56
fix package exports (#296)
Brendonovich Jul 15, 2024
589fd59
turborepo
Brendonovich Jul 15, 2024
d755e1b
:tada: release 0.2.4
oscartbeaumont Jul 15, 2024
c2eaac0
Add `turbo`
oscartbeaumont Jul 15, 2024
1d8c3aa
remove svelte build warning
Brendonovich Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ node_modules
/packages/*/dist

# Compiled vscode extension
*.vsix
*.vsix

.svelte-kit
.turbo
71 changes: 27 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rspc"
description = "A blazing fast and easy to use TRPC server for Rust."
version = "0.1.3"
version = "0.2.0"
authors = ["Oscar Beaumont <oscar@otbeaumont.me>"]
edition = "2021"
license = "MIT"
Expand All @@ -11,53 +11,36 @@ documentation = "https://docs.rs/rspc/latest/rspc"
keywords = ["async", "specta", "rust-to-ts", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]

# /bin/sh RUSTDOCFLAGS="--cfg docsrs2" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs2",
] # TODO: Rename to `docsrs` once Tokio fixes https://github.com/tokio-rs/tokio/pull/6360

[features]
default = []
tauri = ["dep:tauri"]
specta2 = ["dep:specta2"]
tracing = ["dep:tracing"]
httpz = ["dep:httpz", "httpz/cookies"]
# openapi = ["dep:openapiv3"]
# playground = []

# Webservers
axum = ["httpz", "httpz/axum", "httpz/tokio-ws", "httpz/axum"]
# actix-web = ["httpz/actix-web"]
# poem = ["httpz/poem"]
# rocket = ["httpz/rocket"]
# warp = ["httpz/warp"]
# TODO: Following ones are exposed but not officially supported
lambda = ["httpz", "httpz/lambda", "httpz/ws", "httpz/axum"]
workers = ["httpz", "httpz/workers", "httpz/ws"]

# Specta
uuid = ["specta/uuid"]
chrono = ["specta/chrono"]
time = ["specta/time"]
bigdecimal = ["specta/bigdecimal"]
rust_decimal = ["specta/rust_decimal"]
indexmap = ["specta/indexmap"]
ipnetwork = ["specta/ipnetwork"]
mac_address = ["specta/mac_address"]
bit-vec = ["specta/bit-vec"]
bson = ["specta/bson"]

[dependencies]
specta = { version = "1.0.0", features = ["serde", "typescript"] }
httpz = { version = "0.0.4", optional = true } # TODO: Move back to crates.io release
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
thiserror = "1.0.38"
futures = "0.3.26"
tokio = { version = "1.26.0", features = ["sync", "rt", "macros"] }
tauri = { version = "1.2.4", optional = true }
tracing = { version = "0.1.37", optional = true }

[dev-dependencies]
async-stream = "0.3.4"
specta = { version = "1.0.5", features = ["serde", "typescript"] }
specta2 = { package = "specta", optional = true, version = "=2.0.0-rc.11", features = [
"serde",
"typescript",
"interop",
] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114" # TODO: Drop this
thiserror = "1.0.58"
futures = "0.3.30"
tokio = { version = "1.36.0", features = ["sync", "rt", "macros"] }
tracing = { version = "0.1.40", optional = true }

[workspace]
members = [
"./create-rspc-app",
"./examples",
"./examples/axum",
]
members = ["./crates/*", "./examples", "./examples/axum"]

[patch.crates-io]
# Interop support
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "d32f7189246e821f1152c0b78d43fcc3eebfd8fd" }
34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"files": {
"include": ["packages/**"],
"ignore": ["node_modules", "dist"]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"style": {
"noNonNullAssertion": "off"
},
"correctness": {
"useJsxKeyInIterable": "off"
}
}
},
"formatter": {
"indentStyle": "tab"
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
}
}
33 changes: 33 additions & 0 deletions crates/axum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "rspc-axum"
description = "Axum adapter for rspc"
version = "0.1.1"
authors = ["Oscar Beaumont <oscar@otbeaumont.me>"]
edition = "2021"
license = "MIT"
repository = "https://github.com/oscartbeaumont/rspc"
documentation = "https://docs.rs/rspc-axum/latest/rspc-axum"
keywords = ["async", "specta", "rust-to-ts", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]

# /bin/sh RUSTDOCFLAGS="--cfg docsrs2" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs2",
] # TODO: Rename to `docsrs` once Tokio fixes https://github.com/tokio-rs/tokio/pull/6360

[features]
default = []
ws = ["dep:tokio", "axum/ws"]

[dependencies]
rspc = { version = "0.2.0", path = "../.." }
axum = "0.7.4"
serde_json = "1.0.114"

# TODO: Drop these
form_urlencoded = "1.2.1" # TODO: use Axum's built in extractor
futures = "0.3.30" # TODO: No blocking execution, etc
tokio = { version = "1.36.0", optional = true } # TODO: No more `tokio::select` + spawning threads. Axum's Websocket upgrade handles that.
73 changes: 73 additions & 0 deletions crates/axum/src/extractors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use axum::{extract::FromRequestParts, http::request::Parts};
use rspc::ExecError;
use std::future::Future;

use std::marker::PhantomData;

pub trait TCtxFunc<TCtx, TState, TMarker>: Clone + Send + Sync + 'static
where
TState: Send + Sync,
TCtx: Send + 'static,
{
fn exec(
&self,
parts: Parts,
state: &TState,
) -> impl Future<Output = Result<TCtx, ExecError>> + Send;
}

pub struct ZeroArgMarker;

impl<TCtx, TFunc, TState> TCtxFunc<TCtx, TState, ZeroArgMarker> for TFunc
where
TFunc: Fn() -> TCtx + Clone + Send + Sync + 'static,
TState: Send + Sync,
TCtx: Send + 'static,
{
async fn exec(&self, _: Parts, _: &TState) -> Result<TCtx, ExecError> {
Ok(self.clone()())
}
}

macro_rules! impl_fn {
($marker:ident; $($generics:ident),*) => {
#[allow(unused_parens)]
pub struct $marker<$($generics),*>(PhantomData<($($generics),*)>);

impl<TCtx, TFunc, TState, $($generics: FromRequestParts<TState> + Send),*> TCtxFunc<TCtx, TState, $marker<$($generics),*>> for TFunc
where
TFunc: Fn($($generics),*) -> TCtx +Clone + Send + Sync + 'static,
TState: Send + Sync,
TCtx: Send + 'static
{
async fn exec(&self, mut parts: Parts, state: &TState) -> Result<TCtx, ExecError>
{
$(
#[allow(non_snake_case)]
let Ok($generics) = $generics::from_request_parts(&mut parts, &state).await else {
return Err(ExecError::AxumExtractorError)
};
)*

Ok(self.clone()($($generics),*))
}
}
};
}

impl_fn!(OneArgMarker; T1);
impl_fn!(TwoArgMarker; T1, T2);
impl_fn!(ThreeArgMarker; T1, T2, T3);
impl_fn!(FourArgMarker; T1, T2, T3, T4);
impl_fn!(FiveArgMarker; T1, T2, T3, T4, T5);
impl_fn!(SixArgMarker; T1, T2, T3, T4, T5, T6);
impl_fn!(SevenArgMarker; T1, T2, T3, T4, T5, T6, T7);
impl_fn!(EightArgMarker; T1, T2, T3, T4, T5, T6, T7, T8);
impl_fn!(NineArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9);
impl_fn!(TenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
impl_fn!(ElevenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11);
impl_fn!(TwelveArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12);
impl_fn!(ThirteenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13);
impl_fn!(FourteenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14);
impl_fn!(FifteenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15);
impl_fn!(SixteenArgMarker; T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16);
Loading