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

Reboot #249

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
63702fd
Upgrade Specta + drop benchmarks
oscartbeaumont Dec 26, 2023
6ca35be
Drop `crate-rspc-app` for now
oscartbeaumont Dec 26, 2023
50ba4c3
Drop Vercel example
oscartbeaumont Dec 26, 2023
e1cde93
wip
oscartbeaumont Dec 27, 2023
9fef14d
some more work
oscartbeaumont Dec 27, 2023
80ca60c
`Pin` all the way to hospital
oscartbeaumont Dec 27, 2023
0b25409
empty out core
oscartbeaumont Dec 27, 2023
bdb1820
merge core2 into core
oscartbeaumont Dec 27, 2023
38ac9eb
Drop Next.js example
oscartbeaumont Dec 27, 2023
5c3cddc
Remove `Body` and Tauri test
oscartbeaumont Dec 27, 2023
a51c5f5
Drop arg mapper API
oscartbeaumont Dec 27, 2023
3d2e8ac
removing features
oscartbeaumont Dec 27, 2023
ba3baa1
make it build at least
oscartbeaumont Dec 28, 2023
061f828
Unseal & private `MiddlewareBuilder`
oscartbeaumont Dec 29, 2023
7fd4ab6
wip
oscartbeaumont Dec 29, 2023
1ac688e
Remove `StreamToBody`
oscartbeaumont Dec 29, 2023
6bf9d8f
Erase generics earlier
oscartbeaumont Dec 29, 2023
1d82093
layer erasing
oscartbeaumont Dec 29, 2023
be922b6
Split layer and middleware concerns
oscartbeaumont Dec 29, 2023
c23fdb5
Remove `resolver` module
oscartbeaumont Dec 29, 2023
883aacf
move `Layer` and `DynLayer`
oscartbeaumont Dec 29, 2023
ce9334e
move it
oscartbeaumont Dec 29, 2023
f9eafa4
slightly cleanup exports
oscartbeaumont Dec 29, 2023
e961c84
build `rspc_core::Procedure` in `rspc::Procedure::query`/etc
oscartbeaumont Dec 29, 2023
210f3de
redo layer + finally drop `MiddlewareLayer`
oscartbeaumont Dec 29, 2023
93751b9
wip: `LayerResult`
oscartbeaumont Dec 29, 2023
5e65dad
more wip but wrong approach
oscartbeaumont Dec 29, 2023
3cfe083
christmas came early
oscartbeaumont Dec 29, 2023
180a238
new mw system prototype
oscartbeaumont Dec 29, 2023
5489b64
wip: new middleware system
oscartbeaumont Dec 31, 2023
93bf990
wip
oscartbeaumont Dec 31, 2023
22d6b2b
wip
oscartbeaumont Dec 31, 2023
187f088
working middleware
oscartbeaumont Dec 31, 2023
915e6ab
assorted notes
oscartbeaumont Dec 31, 2023
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
39 changes: 11 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,36 @@ categories = ["web-programming", "asynchronous"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[[test]]
name = "tests"
path = "tests/tauri/tauri_test.rs"
harness = false

[[bench]]
name = "benchmarks"
harness = false

[features]
default = ["typescript"]
typescript = ["rspc-core/typescript", "specta/typescript"]
tracing = ["rspc-core/tracing", "dep:tracing"]

unstable = ["rspc-core/unstable"] # APIs where one line of code can blow up your whole app
default = []
tracing = ["dep:tracing"]

[dependencies]
rspc-core = { path = "./crates/core" }
rspc-core = { version = "0.0.1", path = "./crates/core" }
specta = { workspace = true }

serde = { workspace = true }
thiserror = { workspace = true }
futures = { version = "0.3.28", default-features = false, features = ["std", "async-await"] } # TODO: Drop for `futures_core` if possible
pin-project-lite = "0.2.13"
futures = { version = "0.3.30", default-features = false, features = ["std", "async-await"] } # TODO: Drop for `futures_core` if possible

# Optional
serde_json = { version = "1", default-features = false }
tracing = { version = "0.1.40", default-features = false, optional = true }

# Even though this `cfg` can never be enabled, it still forces cargo to keep `rspc-core` in lockstep with `rspc`.
[target.'cfg(any())'.dependencies]
rspc-core = { version = "=1.0.0-rc.5", path = "./crates/core" }

# TODO: Remove `serde_json`
serde_json = { version = "1", default-features = false }

[dev-dependencies]
# Tests
async-stream = "0.3.5"
tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] }
tauri = { version = "1.5.2", features = ["api-all"] }

# Benchmark
criterion = { version = "0.5", features = ["async_tokio", "html_reports"] }
pprof = { version = "0.13.0", features = ["flamegraph", "criterion", "protobuf-codec", "frame-pointer"] }

[workspace]
members = ["./crates/*", "./examples", "./examples/axum", "./examples/vercel", "./examples/tauri/src-tauri"]
members = ["./crates/*", "./examples", "./examples/axum", "./examples/tauri/src-tauri"]


# TODO: Probs remove this
[workspace.dependencies]
specta = { version = "=2.0.0-rc.6", default-features = false, features = ["serde", "serde_json"] }
specta = { version = "=2.0.0-rc.7", default-features = false, features = ["serde", "serde_json", "typescript"] }
serde = { version = "1", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.50", default-features = false }
312 changes: 0 additions & 312 deletions benches/benchmarks.rs

This file was deleted.

13 changes: 13 additions & 0 deletions crates/axum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "rspc-axum"
version = "0.0.1"
edition = "2021"

# /bin/sh RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
axum = { version = "0.7.2", no-default-features = true }
rspc-core = { version = "0.0.1", path = "../core", default-features = false }
43 changes: 43 additions & 0 deletions crates/axum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! Integrate rspc with an [Axum](https://docs.rs/axum/latest/axum/) HTTP server so it can be accessed from your frontend.
#![warn(
clippy::all,
clippy::cargo,
clippy::unwrap_used,
clippy::panic,
clippy::todo,
clippy::panic_in_result_fn,
// missing_docs
)]
#![forbid(unsafe_code)]
#![allow(clippy::module_inception)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use axum::{
extract::Request,
http::{Method, StatusCode},
routing::{on, MethodFilter},
Router,
};
use rspc_core::IntoRouter;

// TODO: Async context function
// TODO: Allow context function to access request

pub fn endpoint<R: IntoRouter>(router: R, ctx_fn: impl Fn() -> R::Ctx) -> Router {
let executor = router.build();
Router::new().route(
"/:id",
on(
MethodFilter::GET.or(MethodFilter::POST),
|req: Request| async move {
match (req.method(), &req.uri().path()[1..]) {
(&Method::GET, "ws") => todo!(), // handle_websocket(router, ctx_fn, req).into_response(),
(&Method::GET, _) => todo!(), // handle_http(router, ctx_fn, req).await.into_response(),
(&Method::POST, "_batch") => todo!(), // handle_http_batch(router, ctx_fn, req).await.into_response()
(&Method::POST, _) => todo!(), // handle_http(router, ctx_fn, req).await.into_response(),
_ => (StatusCode::METHOD_NOT_ALLOWED, Vec::<u8>::new()),
}
},
),
)
}
39 changes: 18 additions & 21 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
[package]
name = "rspc-core"
version = "1.0.0-rc.5"
version = "0.0.1"
edition = "2021"
publish = false # TODO

# TODO: Remove all features from this crate cause they mean we can optimise build time
[features]
default = []
typescript = ["specta/typescript"]
tracing = ["dep:tracing"]
unstable = []
# /bin/sh RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
specta = { workspace = true, features = ["typescript"] } # TODO: `typescript` should be required
serde = { workspace = true }
thiserror = { workspace = true }
futures = { version = "0.3.28", default-features = false, features = ["std", "async-await"] } # TODO: Drop for `futures_core` if possible
pin-project-lite = "0.2.13"
serde_json = { version = "1", default-features = false }
streamunordered = "0.5.3"
# Public API
futures-core = "0.3"
serde = "1"

# TODO: Remove these from core
tracing = { version = "0.1.40", default-features = false, optional = true }
# Private API
erased-serde = "0.4.1"

# TODO: Make something like this work
# # Even though this `cfg` can never be enabled, it still forces cargo to keep `rspc-core` in lockstep with `rspc-*`.
# [target.'cfg(any())'.dependencies]
# rspc-httpz = { version = "=1.0.0-rc.5", path = "../httpz" }
# rspc-tauri = { version = "=1.0.0-rc.5", path = "../tauri" }
# TODO: Remove
serde-value = "0.7.0"

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
serde_json = "1" # TODO: Remove this
futures = "0.3"
28 changes: 0 additions & 28 deletions crates/core/src/body/body.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/core/src/body/mod.rs

This file was deleted.

46 changes: 0 additions & 46 deletions crates/core/src/body/once.rs

This file was deleted.

Loading