tursodatabase / embedded-replicas-with-rust

A simple web traffic analytics tracking API featuring Turso & Acti.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Embedded Replicas with Rust

A simple web traffic analytics tracking API featuring Turso embedded replicas and Actix.

Development

Create a turso database.

turso db create <db-name>

Get the database credentials:

# db url
turso db show --url <db-name>

# authentication token
turso db tokens create <db-name>

Rename .env.example to .env and update the database credentials:

TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=

Run project

mkdir -p db && cargo run

Send Requests

Add a new hit:

curl "http://127.0.0.1:$PORT/record" \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{"title": "About","link": "about-page"}'

Get traffic analytics for a page:

curl "http://127.0.0.1:$PORT/hits?link=about-page"

Note

Info The $PORT above is the value you used in the PORT key inside the .env file.

About

A simple web traffic analytics tracking API featuring Turso & Acti.

License:MIT License


Languages

Language:Rust 96.4%Language:Dockerfile 3.6%