Skip to content

Commit fe134d4

Browse files
committed
misc setup
1 parent 49ebe67 commit fe134d4

13 files changed

Lines changed: 764 additions & 20 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ panic = "abort"
5656

5757
[package.metadata.leptos]
5858
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
59-
output-name = "new-avored"
59+
output-name = "avored-rust-cms"
6060

6161
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
6262
site-root = "target/site"
@@ -65,8 +65,6 @@ site-root = "target/site"
6565
# Defaults to pkg
6666
site-pkg-dir = "pkg"
6767

68-
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
69-
style-file = "style/main.scss"
7068
# Assets source dir. All files found here will be copied and synchronized to site-root.
7169
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
7270
#

build.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
fn main() -> Result<(), Box<dyn std::error::Error>> {
2-
tonic_prost_build::compile_protos("proto/helloworld.proto")?;
2+
3+
let proto_root = "./proto";
4+
let proto_files = &[
5+
"helloworld.proto",
6+
"misc.proto",
7+
// "auth.proto",
8+
// "dashboard.proto",
9+
// "admin_user.proto",
10+
// "content.proto",
11+
// "setting.proto",
12+
// "cms.proto",
13+
// "general.proto",
14+
// "asset.proto",
15+
// "security_audit.proto",
16+
];
17+
18+
let proto_out_dir = "src/infra/grpc";
19+
20+
tonic_prost_build::configure()
21+
.out_dir(proto_out_dir)
22+
.build_server(true)
23+
.compile_protos(proto_files, &[proto_root])?;
24+
25+
26+
// tonic_prost_build::compile_protos("proto/helloworld.proto")?;
327
Ok(())
428
}

proto/misc.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
syntax = "proto3";
2+
3+
package misc;
4+
5+
6+
message HealthCheckRequest {
7+
}
8+
9+
message HealthCheckResponse {
10+
bool status = 1;
11+
}
12+
13+
14+
// Misc is a simple service that provides miscellaneous RPC methods.
15+
service Misc {
16+
// HealthCheck is a simple RPC method that can be used to check the health of the service.
17+
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
18+
}

src/grpc_server.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#[cfg(feature = "ssr")]
22
use tonic::{Request, Response, Status};
33

4-
pub mod helloworld {
5-
tonic::include_proto!("helloworld");
6-
}
4+
use crate::infra::grpc::helloworld::{HelloReply, HelloRequest, greeter_server::Greeter};
5+
6+
77

8-
use helloworld::greeter_server::Greeter;
9-
use helloworld::{HelloReply, HelloRequest};
108

119
#[derive(Debug, Default)]
1210
pub struct MyGreeter {}

src/infra/app.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ pub async fn create_app(state: AppState) -> crate::error::Result<Router> {
1616
// Generate the list of routes in your Leptos App
1717
let routes = generate_route_list(App);
1818

19-
let greeter = crate::grpc_server::MyGreeter::default();
20-
let grpc_service =
21-
crate::grpc_server::helloworld::greeter_server::GreeterServer::new(greeter);
19+
let my_hello_server = crate::grpc_server::MyGreeter::default();
20+
let my_hello_service =
21+
crate::infra::grpc::helloworld::greeter_server::GreeterServer::new(my_hello_server);
22+
23+
let my_misc_server = crate::infra::grpc::misc_server::MyMisc::default();
24+
let my_misc_service =
25+
crate::infra::grpc::misc::misc_server::MiscServer::new(my_misc_server);
2226

2327
let router = Router::<AppState>::new()
24-
.route_service("/helloworld.Greeter/SayHello", grpc_service)
28+
.route_service("/helloworld.Greeter/SayHello", my_hello_service)
29+
.route_service("/misc.Misc/HealthCheck", my_misc_service)
2530
.leptos_routes_with_context(
2631
&state,
2732
routes,

0 commit comments

Comments
 (0)