All Projects → steadylearner → Rust-Warp-Example

steadylearner / Rust-Warp-Example

Licence: other
Rust Warp example by Steadylearner

Programming Languages

rust
11053 projects
CSS
56736 projects

Projects that are alternatives of or similar to Rust-Warp-Example

boilerplate-nexus-prisma-apollo-graphql-express
Boilerplate project for a graphql server using nexus-prisma and apollo-server-express
Stars: ✭ 31 (+72.22%)
Mutual labels:  backend-server
wordops-dashboard
Dashboard for WordOps backend
Stars: ✭ 35 (+94.44%)
Mutual labels:  backend-server
civic-server
Backend Server for CIViC Project
Stars: ✭ 39 (+116.67%)
Mutual labels:  backend-server
EosProxyServer
A full-functional backend server of EOS wallet.
Stars: ✭ 36 (+100%)
Mutual labels:  backend-server
json-fake-server
Simple way to create http server (node js) https://www.npmjs.com/package/test-fake-server
Stars: ✭ 15 (-16.67%)
Mutual labels:  backend-server

Rust Warp backend server

This is a Rust Warp backend server prototype for the demo video below. I made it for a freelance client as a POF a few months before. I had a freedom to use the language for a backend server. So, I used Rust to prove myself that I can do it with Rust. If I have to do it again, I would use Python.

React Rust demo

I share it because I have to send some private works for Rust working opportunity. If I have to, I prefer it to be an open source.

If writing Rust were easy and take less time, I would rewrite. You can imporve it yourselves with TODO list below.

The payload will be session.rs file.

How to test it

You can use $python3 dev.py or $cargo run --bin main or $RUST_LOG=debug cargo run --bin main to test a web server.

If you want to start simple, start with hello and hi apis.

You can also test other CLI commands with cargo run --bin name. Refer to Cargo.toml for that.

End points

I let CURL commands for each files in routes/ folder to help you test the end points. But, you can start with these first.

  • Register a user
$curl -X POST localhost:8000/api/user/v1 -H "Content-Type: application/json" -d '{ "email": "[email protected]", "password": "password" }'
  • List users
$curl localhost:8000/api/user/v1
  • Login
curl -X POST localhost:8000/api/user/v1/login -c cookie.txt -H "Content-Type: application/json" -d '{ "email": "[email protected]", "password": "password" }'
  • Update cash
$curl -X PATCH localhost:8000/api/user/v1/cash -b cookie.txt -L -H "Content-Type: application/json" -d '{ "amount": 100000 }'
  • Buy a car
$curl -X POST localhost:8000/api/user/v1/car -b cookie.txt -L -H "Content-Type: application/json" -d '{ "price": 10000, "color": "red" }'
  • List cars
$curl -X GET localhost:8000/api/user/v1/car -b cookie.txt -L
  • Gamble with cash
$curl -X POST localhost:8000/api/user/v1/game -b cookie.txt -L -H "Content-Type: application/json" -d '{ "stake_amount": 10000, "car_id": null, "number_of_participants": 2 }'
  • Gamble with a car
$curl -X POST localhost:8000/api/user/v1/game -b cookie.txt -L -H "Content-Type: application/json" -d '{ "stake_amount": 10000, "car_id": null, "number_of_participants": 2 }'
  • Ranking
$curl localhost:8000/api/ranking/v1/game
  • Delete a user
$curl -X GET localhost:8000/api/user/v1/logout -b cookie.txt -L

TODO

This was just a prototype to clone a function of a gambling website. It is far from perfect. I will include some lists that you can improve.

If you want working Rust code to reuse, refer to the Rust Full Stack repository.

I did code with it a few months ago so they are only what I can think currently instead of investing so much time to read all code again.

There are not many Rust web server examples. I wouldn't write this way again if the development were for myself. But, hope you can save the compile time with it at least.

Frontend part is up to you. You can implement it on your own referring to the example above.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].