A simple RESTful API built with Rust🦀, utilizing the Rocket framework and Diesel ORM for PostgreSQL database interactions.
- User registration with secure password hashing
- CRUD operations for user management
- PostgreSQL integration using Diesel ORM
- Environment configuration via
.env - Connection pooling with
r2d2 - JSON serialization/deserialization with
serde
- Rust (latest stable version)
- PostgreSQL
- Diesel CLI
-
Clone the repository:
git clone https://github.com/filipe-freitas-dev/user_register_api.git cd user_register_api -
Set up environment variables: Create a
.envfile in the root directory and add your database URL:DATABASE_URL=postgres://username:password@localhost/database_name JWT_SECRET=yoursupersecret
-
Install Diesel CLI (if not already installed):
cargo install diesel_cli --no-default-features --features postgres
-
Run database migrations:
diesel setup diesel migration run
-
Build and run the application:
cargo run
| Method | Endpoint | Description |
|---|---|---|
| POST | /users |
Create a new user |
| GET | /users |
Retrieve all users |
| GET | /users/{id} |
Retrieve user by ID |
| PUT | /users/{id} |
Update user by ID |
| DELETE | /users/{id} |
Delete user by ID |
| POST | /admins |
Create admin user |
| POST | /login |
Athenticate a user |
This project is licensed under the MIT License.