Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tursodatabase/embedded-replicas-with-rust

A simple web traffic analytics tracking API featuring Turso & Acti.
https://github.com/tursodatabase/embedded-replicas-with-rust

actix-web libsql rust sqlite turso

Last synced: 20 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# Embedded Replicas with Rust

A simple web traffic analytics tracking API featuring [Turso embedded replicas](https://docs.turso.tech/features/embedded-replicas) and [Actix](https://github.com/actix/actix-web).

## Development

Create a turso database.

```sh
turso db create
```

Get the database credentials:

```sh
# db url
turso db show --url

# authentication token
turso db tokens create
```

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

```text
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=
```

## Run project

```sh
mkdir -p db && cargo run
```

## Send Requests

Add a new hit:

```sh
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:

```sh
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.