sea-orm/examples/jsonrpsee_example
darkmmon 84be56e01a
update example's dependency versions (#1759)
* version update, all examples marked with #notcomplete does not compile with cargo run

* WIP

* salvo example fixed

* testing, and boost a minor version

* fmt

* build dependency update

* CI

* cleanup

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-07-25 16:12:44 +08:00
..
2023-07-08 00:14:02 +08:00
2023-07-13 10:36:56 +01:00
2023-07-08 00:14:02 +08:00

jsonrpsee with SeaORM example app

  1. Modify the DATABASE_URL var in .env to point to your chosen database

  2. Turn on the appropriate database feature for your chosen db in service/Cargo.toml (the "sqlx-sqlite", line)

  3. Execute cargo run to start the server

  4. Send jsonrpc request to server

#insert
curl --location --request POST 'http://127.0.0.1:8000' \
--header 'Content-Type: application/json' \
--data-raw '{"jsonrpc": "2.0", "method": "Post.Insert", "params": [
    {
        "id":0,
        "title":"aaaaaaa",
        "text":"aaaaaaa"
    }
], "id": 2}'

#list
curl --location --request POST 'http://127.0.0.1:8000' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "Post.List",
    "params": [
        1,
        100
    ],
    "id": 2
}'

#delete
curl --location --request POST 'http://127.0.0.1:8000' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "Post.Delete",
    "params": [
        10
    ],
    "id": 2
}'

#update
curl --location --request POST 'http://127.0.0.1:8000' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "Post.Update",
    "params": [
        {
            "id": 1,
            "title": "1111",
            "text": "11111"
        }
    ],
    "id": 2
}'

Run mock test on the service logic crate:

cd service
cargo test --features mock