{"id":25066072,"url":"https://github.com/benjaminpla/actix_api","last_synced_at":"2025-10-09T07:12:11.297Z","repository":{"id":250768013,"uuid":"835407629","full_name":"benjaminPla/actix_api","owner":"benjaminPla","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-06T08:08:24.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T14:04:38.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benjaminPla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-29T19:18:15.000Z","updated_at":"2024-08-06T08:08:27.000Z","dependencies_parsed_at":"2024-08-06T09:57:32.103Z","dependency_job_id":"6fed38f0-c5e8-4f02-8fa1-89409c7a2379","html_url":"https://github.com/benjaminPla/actix_api","commit_stats":null,"previous_names":["benjaminpla/actix_api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benjaminPla/actix_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminPla%2Factix_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminPla%2Factix_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminPla%2Factix_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminPla%2Factix_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjaminPla","download_url":"https://codeload.github.com/benjaminPla/actix_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminPla%2Factix_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000983,"owners_count":26082971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-06T20:00:14.619Z","updated_at":"2025-10-09T07:12:11.276Z","avatar_url":"https://github.com/benjaminPla.png","language":"Rust","readme":"# Actix API | Rust\n\n## Overview\n\nThis project demonstrates a web API built using Actix Web and Rust. The API uses SQLite (in-memory) for database operations, and includes basic user management functionalities with password encryption and JWT authentication. Environment variables are used for configuration, and Actix provides high-performance web handling.\n\n## Project Structure\n\n```\n.\n├── Cargo.lock\n├── Cargo.toml\n├── src\n│   ├── controllers\n│   │   ├── authentication.rs\n│   │   ├── mod.rs\n│   │   └── users.rs\n│   ├── main.rs\n│   ├── types\n│   │   ├── authentication.rs\n│   │   ├── mod.rs\n│   │   └── users.rs\n│   └── utils\n│   └── mod.rs\n└── todo.md\n```\n\n## Features\n\n- **Password Encryption:** Uses Argon2 for securely hashing and verifying passwords.\n- **JWT Authentication:** Implements JSON Web Tokens (JWT) for secure user authentication.\n\n## Database\n\nThis project uses an in-memory SQLite database provided by `rusqlite`. The database schema is created dynamically during runtime.\n\n## Configuration\n\nTo configure the project, follow these steps:\n\n1. **Create a `.env` file in the project root** and add the necessary environment variables:\n\n   ```env\n   HOST='127.0.0.1'\n   JWT_SECRET_KEY='jwt_secret_key'\n   NEW_ADMIN_PASSWORD='12345'\n   PORT=8080\n   ```\n\n2. The `HOST` and `PORT` variables define the address and port the server will listen to. The `NEW_ADMIN_PASSWORD` is used to create an initial admin user. The `SECRET_KEY` is used for signing JWTs.\n\n## Running Locally\n\nTo run the project locally, follow these steps:\n\n1. **Install project dependencies** using Cargo:\n\n   ```bash\n   cargo build\n   ```\n\n2. **Run the server**:\n\n   ```bash\n   cargo run\n   ```\n\n   The server will start on the address defined by the `HOST` and `PORT` environment variables.\n\n## Endpoints\n\nThis project provides the following API endpoints:\n\n| Endpoint                        | Description                                      | HTTP Method |\n| ------------------------------- | ------------------------------------------------ | ----------- |\n| `/login`                        | User login endpoint, requires email and password | POST        |\n| `/status`                       | Check server status                              | GET         |\n| `/users/create_user`            | Create a new user                                | POST        |\n| `/users/delete_user_by_id/{id}` | Delete a user by id                              | DELETE      |\n| `/users/get_users`              | Retrieve a list of all users (admin only)        | GET         |\n| `/users/update_user_by_id/{id}` | Update a user by id                              | PUT         |\n\n### JWT Authentication\n\n- **`/login`**: Provides a JWT token upon successful authentication. The token must be included in the `Authorization` header for requests to protected endpoints.\n\n- **Protected Endpoints**: The `/users/get_users` endpoint requires the user to be an admin (`is_admin` field set to `true`). The JWT token is validated, and only users with the admin role can access this endpoint.\n\n## Images\n\n![image](https://github.com/user-attachments/assets/72bfae49-5405-49c5-9438-7192f72357c5)\n\n![image](https://github.com/user-attachments/assets/dc69cc3d-8320-443a-96fc-247f969b1d1f)\n\n![image](https://github.com/user-attachments/assets/36df2b64-6bd7-481a-a491-6465148c3a31)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminpla%2Factix_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjaminpla%2Factix_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminpla%2Factix_api/lists"}