Skip to content

Commit ebe2bf6

Browse files
author
Your Name
committed
add rpc types
1 parent 7bf622a commit ebe2bf6

File tree

6 files changed

+57
-19
lines changed

6 files changed

+57
-19
lines changed

.generated/RPCMethod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export type RPCMethod = { BotApprove: { bot_id: string, reason: string, } } | { BotDeny: { bot_id: string, reason: string, } } | { BotVoteReset: { bot_id: string, reason: string, } } | { BotVoteResetAll: { reason: string, } } | { BotUnverify: { bot_id: string, reason: string, } };

.generated/RPCRequest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
import type { RPCMethod } from "./RPCMethod";
3+
4+
export interface RPCRequest { user_id: string, token: string, method: RPCMethod, protocol: number, }

Cargo.lock

Lines changed: 30 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ devrun:
2020
DATABASE_URL=$(DATABASE_URL) RUSTFLAGS=$(RUSTFLAGS_LOCAL) cargo run
2121
cross:
2222
DATABASE_URL=$(DATABASE_URL) CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=$(CARGO_TARGET_GNU_LINKER) cargo build --target=x86_64-unknown-linux-gnu --release ${ARGS}
23+
copybindings:
24+
DATABASE_URL=$(DATABASE_URL) cargo test ${ARGS}
25+
@# For every binding in the .generated folder created, copy via SCP to /iblseed/apiBindings
26+
27+
ssh root@$(HOST) "mkdir -p /iblseeds/apiBindings"
28+
29+
@for file in $(shell ls .generated) ; do \
30+
echo "Copying $$file to $(HOST):/iblseeds/apiBindings/$$(basename $$file)"; \
31+
scp -C .generated/$$file root@$(HOST):/iblseeds/apiBindings/$$(basename $$file); \
32+
done
2333
push:
2434
@for bin in $(BINS) ; do \
2535
echo "Pushing $$bin to $(HOST):${PROJ_NAME}/$$bin/$$bin.new"; \
2636
scp -C target/x86_64-unknown-linux-gnu/release/$$bin root@$(HOST):${PROJ_NAME}/$$bin/$$bin.new; \
2737
done
38+
make copybindings
2839
remote:
2940
ssh root@$(HOST)
3041
up:

api/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ actix-cors = "0.6.4"
1111
tokio = "1.20.0"
1212
actix-rt = "2.6.0"
1313
sqlx = { version = "0.6", features = [ "runtime-actix-rustls" , "postgres", "chrono", "uuid", "bigdecimal", "json"] }
14-
futures = "0.3.21"
15-
futures-util = "0.3"
1614
serde = { version = "1.0", features = ["derive"] }
1715
serde_json = { version = "1.0.61", features = ["preserve_order"] }
1816
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "next", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http", "cache"] }
@@ -21,4 +19,5 @@ chrono = { version = "0.4.19", features = ["serde"]}
2119
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "rustls-tls-native-roots"] }
2220
log = "0.4"
2321
env_logger = "0.9"
24-
moka = { version = "0.9", features = ["future"] }
22+
moka = { version = "0.9", features = ["future"] }
23+
ts-rs = "6.2"

api/src/models.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ use serde::{Deserialize};
33
use moka::future::Cache;
44
use sqlx::PgPool;
55

6+
// For frontend API interface generation
7+
use ts_rs::TS;
8+
69
pub struct AppState {
710
pub cache_http: CacheHttpImpl,
811
pub pool: PgPool,
912
pub ratelimits: Cache<String, u64>,
1013
}
1114

12-
#[derive(Deserialize)]
15+
#[derive(Deserialize, TS)]
16+
#[ts(export, export_to="../.generated/RPCRequest.ts")]
1317
pub struct RPCRequest {
1418
pub user_id: String,
1519
pub token: String,
1620
pub method: RPCMethod,
1721
pub protocol: u8,
1822
}
1923

20-
#[derive(Deserialize)]
24+
#[derive(Deserialize, TS)]
25+
#[ts(export, export_to="../.generated/RPCMethod.ts")]
2126
pub enum RPCMethod {
2227
BotApprove { bot_id: String, reason: String },
2328
BotDeny { bot_id: String, reason: String },

0 commit comments

Comments
 (0)