Collection of Rust libraries, frameworks and programs to build better Internet.
Server Kit is a simply configurable backend framework based on Salvo. It is simple enough and powerful.
Server Kit provides DSL-to-API prototype translator to simplify development:
- automated version bumping on breaking changes
- automated OpenAPI spec generation
- automated OpenTelemetry instrumenting.
Static Server is simple frontend-to-client provider built with Server Kit. You can edit static-server.yaml
to specify Server Kit parameters.
On its own, Static Server serves all files from one of distribution folders:
/usr/local/frontend-dist
{CURRENT_EXE_PATH}/dist
And more! It internally redirects all requests without file extension to index.html
, and your SPA apps can run smoothly.
Also, you can use Static Server as a library to include frontend router to your backend application:
let router = cc_server_kit::get_root_router(&state)
.hoop(
affix_state::inject(state.clone())
.inject(setup.clone())
.inject(connect_sea_orm().await?)
.inject(auth_cli),
)
.push(crate::api::auth_router())
.push(crate::api::chat_router())
.push(cc_static_server::frontend_router()); // include it in the end for correct redirects
Also, you can specify distribution path:
...
.push(cc_static_server::frontend_router_from_given_dist(&PathBuf::from("/any/other/folder")));
cc-utils
is a bunch of fullstack utils:
- common error types:
ServerError
,CliError
andErrorResponse
- unified result types:
MResult<T> = Result<T, ServerError>
andCResult<T> = Result<T, CliError>
- backend response types for Salvo and Server Kit:
ok!()
,plain!(str)
,html!(str)
,file_upload!(pathbuf, filename)
,json!(ser)
andmsgpack!(ser)
ExplicitServerWrite
backend trait which uses only&mut Response
to respond unlikeServerResponseWriter::write(self, req, depot, res)
- MsgPack extraction traits for
reqwest::Response
andsalvo::Request
- MsgPack send trait for
reqwest::RequestBuilder
- SIMD JSON support
In a way, cc-utils
is useful in many cases such as error handling and response writing.
UI Kit is just superstructure above Leptos and ThawUI frameworks. It provides:
- simple application entrypoint
- logging support with
log
- automated light/dark themes (with Tailwind support)
- utils to perform request to the backend (
cc_ui_kit::router::endpoint
andcc_ui_kit::router::redirect
functions)
Startup example:
fn main() {
cc_ui_kit::setup_app(log::Level::Info, Box::new(move || { view! { <App /> }.into_any() }))
}
This repository actively uses nightly
toolchain. While these frameworks and libraries are battle-tested anyway, consider not to choose cc-services
to use if you are not aware of nightly
toolchain.