BerryLib is a Rust-based web application framework leveraging Actix Web for building high-performance web services. This project includes modules for controllers, models, routes, services, and middleware, with a focus on authentication and database connectivity.
- Getting Started
- Project Structure
- Features
- Environment Variables
- Running the Application
- Endpoints
- Contributing
- License
- Rust: Install Rust
- PostgreSQL: Install PostgreSQL
-
Clone the repository:
git clone https://github.com/yourusername/berrylib.git cd berrylib -
Set up environment variables: Create a
.envfile in the root directory with the following contents:DATABASE_URL=your_postgres_database_url PORT=8080 SECRET_KEY=your_secret_key
-
Install dependencies and build the project:
cargo build
berrylib/
├── src/
│ ├── controllers/
│ ├── middleware/
│ │ └── auth_middleware.rs
│ ├── models/
│ ├── routes/
│ ├── services/
│ ├── main.rs
│ └── ...
├── .env
├── Cargo.toml
└── README.md
- Actix Web Integration: Leverages Actix Web for high-performance web service development.
- Authentication Middleware: Custom middleware for handling JWT authentication.
- Database Connectivity: Utilizes SQLx for PostgreSQL database operations.
- Environment Configuration: Manages configuration using dotenv.
The application uses the following environment variables, which should be defined in a .env file:
DATABASE_URL: URL of the PostgreSQL database.PORT: Port on which the server will run.SECRET_KEY: Secret key for JWT authentication.
-
Start the PostgreSQL database.
-
Run the application:
cargo run
-
The server will start on the specified port (default is 8080).
POST /auth/login: Authenticate a user and return a JWT.POST /auth/register: Register a new user.
- Define other routes in the
routesmodule.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
- Fork the repository.
- Create a new branch with your feature or bugfix.
- Commit your changes.
- Push to your branch and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.