Rust Actix REST API application with MongoDB
- To minimize the size of binaries, I followed - article. It help me reduce the final binary size from 22M to 6.8M
- Also used cargo-unused-features to cleanup unused features. This helped me reduce from 6.8M to 5.3M.
- Run
unused-features analyze
followed byunused-features prune --input report.json
. More info in the github link above.
- Run
- Basic CRUD calls using MongoDB.
- Environment Config.
- Logging.
- Add JSON validator.
- Add security may be JWT.
- Add role based JWT.
- Global and Local api Error Handling.
- Form bean and Entity bean mapping.
- Add Unit testing.
- Add integration testing.
- Docker build... with minimal base image.
- Pagination & Sorting of get list.
- CORS Support for API.
- Custom validation error.
- Add events (like, auth event, user event etc...) and persist in a MongoDB table.
- Implement Kafka or Pulsar event stream. Preferably Apache pulsar.
- Implement REST API client call using
reqwest
lib. - Redis Cache for frequent calls.
- MscBookPro M1
- Rustup for managing
rustc
and plugins - IDE used are
Intellij IDEA
and Helix Editor. Helix editor is developed using Rust 🦀. - Use Colima. Its a light weight cli alternative to docker desktop.
- Use Starship for shell with fish shell. Another tool developed using Rust 🦀.
- Terminal tool using is
Alacritty
withtmux
.Alacritty
is another rust based 🦀.3
- Working on similar project with
axum
andsqlx
, the srouce code is here
{
"status": 404,
"time": "2022-12-25T15:25:35.089z",
"message": "User not found for id - 2893f9283uo2",
"debugMessage": "User not found for id - 2893f9283uo2",
"subErrors": [
{
"object": "users",
"field": "email",
"rejectedValue": "dummyEmailgmail.com",
"message": "invalid email address"
}
]
}
- Sample request -
[GET] https://.../users?offset=20&limit=20&sort_by=name
- Sample response with three elements -
data
,meta
and_links
.
{
"data": [{
"id": "usr_DwgQxN3gLRX1p0g7bwny1",
"userName": "john_doe",
"firstName": "john",
"lastName": "Doe",
"email": "john_doe@c12.io"
},
{...}
],
"meta": {
"current_page": 1,
"page_size": 20,
"page_count": 12,
"total_results": 348,
"search_id": "VE4heV3F5m2Vf0GO_dLhu",
"search_criteria": "",
"sort_by": "lastName"
},
"_link": {
"self": {
"href": "/v1/users?limt=20&offset=40"
},
"previous": {
"href": "/v1/users?limit=20&offset=20"
},
"first": {
"href": "/v1/users?limit=20&offset=0"
},
"next": {
"href": "/v1/users?limit=20&offset=60"
},
"last": {
"href": "/v1/users?limit=20&offset=120"
}
}
}