Newsletter API
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.
Features
- 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
Dependencies
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 datatracingandtracing-subscriber: Logging and tracing functionalitydotenv: Loading environment variables from a.envfileregex: Regular expression supportsecrecy: Library for managing secrets and sensitive data
Getting Started
-
Clone the repository:
git clone https://github.com/dmcclung/newsletter-api.git -
Set up the required environment variables in a
.envfile. -
Run the database migrations:
-
Build and run the application:
-
The API will be available at
http://localhost:3000.
API Endpoints
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
Testing
To run the tests, use the following command:
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
License
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.