Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/tursodatabase/embedded-replicas-with-rust
- Owner: tursodatabase
- License: mit
- Created: 2024-03-20T12:50:58.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-21T01:20:25.000Z (10 months ago)
- Last Synced: 2024-11-09T22:40:44.582Z (3 months ago)
- Topics: actix-web, libsql, rust, sqlite, turso
- Language: Rust
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.