Go to file
2024-11-02 19:34:53 +02:00
.cargo Initial 2024-11-02 19:34:53 +02:00
migration Initial 2024-11-02 19:34:53 +02:00
src Initial 2024-11-02 19:34:53 +02:00
.env Initial 2024-11-02 19:34:53 +02:00
.gitignore Initial 2024-11-02 19:34:53 +02:00
Cargo.lock Initial 2024-11-02 19:34:53 +02:00
Cargo.toml Initial 2024-11-02 19:34:53 +02:00
db.sqlite Initial 2024-11-02 19:34:53 +02:00
README.md Initial 2024-11-02 19:34:53 +02:00

setup

cargo install sea-orm-cli
sea-orm-cli generate entity -o src/db/models # do this every time you edit the migrations, or first time on clone
cargo build

api docs

u-token = user token p-token = pc token a-token = u-token or p-token pid = cc:t pc id

GET - /ws (nothing required on first req, see ws docs for more info)

POST - /api/user/login (no token (duh), json body with email, pwd, returns json with token) POST - /api/user/add (u-token in header, json body with full user info) POST - /api/user/:id/edit (u-token in header, json body with data to replace with) POST - /api/user/:id/remove (u-token in header, no body required) GET - /api/user/:id/info (u-token in header, get back json)

GET - /api/cct/ (a-token in header, gets a list of all groups) GET - /api/cct/:group/ (a-token in header, gets a list of all pid's) GET - /api/cct/:group/:pid/ (a-token in header, gets a list of all values for that pc) GET - /api/cct/:group/:pid/:val (a-token in header, gets a value from a pc in a group)

POST - /api/cct/group/add (a-token in header, adds a group) POST - /api/cct/:group/edit (a-token in header, edits a group) POST - /api/cct/:group/pc/add (a-token in header, adds a pc to a group) POST - /api/cct/:group/:pid/edit (a-token in header, edits a pc in a group) POST - /api/cct/:group/:pid/val/add (a-token in header, adds a value to a pc in a group) POST - /api/cct/:group/:pid/:val/edit (a-token in header, edits value info in a pc in a group) POST - /api/cct/:group/:pid/:val/set (a-token in header, sets a value in a pc in a group)

========== ws

ws_msg_t: 0: heartbeat ping 1: server to client 2: client to server msg_t: TODO!

{ // low level message
    "ws_msg_t": 0, // `ws_msg_t`
    "ws_msg": { // high level message
        "auth": "Token", // Auth token
        "msg": { // Data field
            "keypad": {
                "DoorOpenEv": { // "DataType": "Value, can be a struct or anything"
                    "user": "uid",
                    "timestamp": 123456,
                    "door_id": "1234-abcd-1234-abcd"
                }
            }
        },  
    }
}