A simple web traffic analytics tracking API featuring Turso embedded replicas and Actix.
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=
mkdir -p db && cargo run
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.