Skip to content

Latest commit

 

History

History

app-web-traffic-tracker-actix

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Web Traffic Tracker

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.