This is a Rust-based application that manages a newsletter API. It provides functionality for handling newsletter subscriptions, sending emails, and managing the associated data.
- User registration and subscription management
- Email sending using the Lettre library
- Database integration with PostgreSQL using SQLx
- RESTful API endpoints using Actix-web
- Environment configuration using dotenv
- Logging with tracing and tracing-subscriber
- UUID generation for unique identifiers
- Date and time handling with Chrono
The main dependencies used in this project are:
actix-web
: Web framework for building the API endpointsaskama
: Template engine for rendering email templateslettre
: Library for sending emailssqlx
: Async PostgreSQL driver with compile-time checked queriesuuid
: Library for generating UUIDschrono
: Date and time libraryserde
: Serialization and deserialization of JSON datatracing
andtracing-subscriber
: Logging and tracing functionalitydotenv
: Loading environment variables from a.env
fileregex
: Regular expression supportsecrecy
: Library for managing secrets and sensitive data
-
Clone the repository:
git clone https://github.com/dmcclung/newsletter-api.git
-
Set up the required environment variables in a
.env
file. -
Run the database migrations:
sqlx migrate run
-
Build and run the application:
cargo run
-
The API will be available at
http://localhost:3000
.
POST /subscriptions
: Subscribe to the newsletterGET /subscriptions
: Get all subscriptionsGET /subscriptions/{id}
: Get a specific subscription by IDDELETE /subscriptions/{id}
: Unsubscribe from the newsletterPOST /newsletter
: Publish a newsletter
To run the tests, use the following command:
cargo test
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
Feel free to customize and enhance the README based on your specific application's features and requirements.