https://github.com/pixelrocket-shop/tutorials-api-newsletter
The public dummy API used for newsletter functionality in my tutorials, courses and projects
https://github.com/pixelrocket-shop/tutorials-api-newsletter
Last synced: over 1 year ago
JSON representation
The public dummy API used for newsletter functionality in my tutorials, courses and projects
- Host: GitHub
- URL: https://github.com/pixelrocket-shop/tutorials-api-newsletter
- Owner: PixelRocket-Shop
- Created: 2024-07-27T17:04:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-28T06:15:31.000Z (almost 2 years ago)
- Last Synced: 2025-02-15T11:16:21.633Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://tutorials-api-newsletter.vercel.app
- Size: 2.46 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Newsletter API
This project is a simple Newsletter API built with Express.js, featuring rate limiting and Swagger documentation. The API allows users to sign up for a newsletter, check if an email is subscribed, and unsubscribe. The subscribers are stored in a JSON file. This API is used in my tutorials, courses, and projects on [pixelrocket.store](https://www.pixelrocket.store).
## Features
- **Rate Limiting:** Prevents abuse by limiting the number of requests per IP address.
- **Swagger Documentation:** Provides a user-friendly interface to interact with the API.
- **JSON File Storage:** Subscriber data is stored in a JSON file for simplicity.
## Getting Started
### Prerequisites
- Node.js and npm installed on your machine.
- Vercel CLI for deployment (optional).
### Installation
1. Clone the repository:
git clone https://github.com/PixelRocket-Shop/tutorials-api-newsletter.git
\
cd newsletter-api
2. Install dependencies:
npm install
### Running the API Locally
1. Start the server:
node src/app.js
2. The API will be running at http://localhost:3000.
3. Access the Swagger documentation at http://localhost:3000/api-docs.
### API Endpoints
#### Sign Up for Newsletter
- **URL:** /newsletter
- **Method:** POST
- **Request Body:**
json
{
"email": "user@example.com"
}
- **Responses:**
- 200 OK: Successfully signed up.
- 400 Bad Request: Email already subscribed.
#### Unsubscribe from Newsletter
- **URL:** /newsletter/{email}
- **Method:** DELETE
- **Parameters:**
- email (string): The email to unsubscribe.
- **Responses:**
- 200 OK: Successfully unsubscribed.
- 404 Not Found: Email not found.
#### Check if Email is Subscribed
- **URL:** /newsletter/{email}
- **Method:** GET
- **Parameters:**
- email (string): The email to check.
- **Responses:**
- 200 OK: Email is subscribed.
- 404 Not Found: Email not subscribed.
### License
This project is licensed under the MIT License.