eiffelfly / curioucity Goto Github PK
View Code? Open in Web Editor NEWKnowledge management tool built for community and its builder using Rust.
Knowledge management tool built for community and its builder using Rust.
All the discord context will be returned as string from Discord API, let do the same in our API
Right now we only support page_size query body for backend to operate simple pagination. But it is not ideal.
Cursor based pagination is far better than limit and offset pagination.
The K6 need to know the proto file of the API to test the API. But when import the proto, the k6 can't find the imported proto from the original file.
Right now we only use javascript to write the integration-test, it's not so elegant in my opinion. We can re-write the whole tests file to typescript file, build by esbuild and output to /dist file and then run the integration-test.
Currently, we use this match pattern in our backend
let discord_message =
match db_third_party::discord::DiscordMessage::create(client, &payload).await {
Ok(discord_message) => discord_message,
Err(error) => {
return Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!(
"Something went wrong when create discord message: {}",
error
),
)
.into_response())
}
};
In order to reduce the overhead of coming up a variable name for Ok(), I purpose that we unify that as below
let discord_message =
match db_third_party::discord::DiscordMessage::create(client, &payload).await {
Ok(result) => result,
Err(error) => {
return Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!(
"Something went wrong when create discord message: {}",
error
),
)
.into_response())
}
};
Instead of coming up a new name, we use result
Currently our REST API endpoint is
GET /resource_name/:resource_id
: get resourceGET /resource_name
: list resourcesPOST /resource_name
: create resourceDELETE /resource_name
with resource_id in body: delete resourceIn order to make it more consistent, I would like to alter the design to
GET /resource_name/:resource_id
: get resourceGET /resource_name
: list resourcesPOST /resource_name/create
: create resourceDELETE /resource_name/:resource_id
with resource_id in body: delete resourceAccording to protobuf spec, int64 will be serialized as string in the form of JSON. Currently, int32 should suit our need enough.
order_in_thread comes from Discord message object's position. It appears to be integer but without specifying the type. I think int32 will be enough to store it.
https://discord.com/developers/docs/resources/channel#message-object
Currently, in our API we provide JSON object and markdown content in the DiscordThread object.
#[derive(Queryable, Serialize, Deserialize, Debug)]
pub struct DiscordThread {
pub id: Uuid,
pub kind: String,
pub thread_id: String,
#[edgedb(json)]
pub full_messages_json: HashMap<String, String>,
pub markdown_content: String,
pub tags: Vec<Tag>,
pub messages: Vec<DiscordMessage>,
pub url: Url,
pub created_timestamp_at_curioucity: String,
pub created_timestamp_at_discord: String,
}
The upcoming questions are
Currently, we have this kind of test to test the list endpoint
check(http.request("GET", `${API_HOST}/tags`, undefined, { headers }), {
"listTag - GET /tags - have two tags, should response 200": (r) =>
r.status === 200,
"listTag - GET /tags - have two tags, should response size=2": (r) =>
r.json().size === "2",
});
Sadly, it will have chance to get polluted by other testing, we may need to find better way to solve it.
Protobuf will serialize int64 to string in the form of JSON.
JSON cannot store 64-bit integers, instead only storing double-precision floats (which have a maximum integral precision of 52-bits)
We better store our timestamp in the form of string like GitHub API 2020-01-10T14:59:22Z
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.