Birthday Wish Mailer is a Node.js project using the Express framework to automatically send a birthday greeting email to registered customers on their birthday. The system uses Node-Cron for scheduling and Nodemailer for simulating email sending in a development environment.
Ensure the following software is installed on your system before you proceed with the setup:
- Docker
- Docker Compose
- Node.js (v12.0.0 or higher)
- npm or yarn (for managing packages)
- Sequelize CLI (for database migrations)
-
Clone the repository:
git clone [your-repository-link] cd birthday-wish-mailer
-
Set up environment variables: Copy the
.env.example
file to create your.env
file:cp .env.example .env
Edit the
.env
file to fill in the environment-specific variables such as database credentials and any other necessary configurations. -
Run Docker Compose: To set up and run the Postgres database on Docker, execute the following command:
docker-compose up -d
-
Install dependencies: Install all required npm packages by running:
npm install
-
Run migrations: Apply database migrations using Sequelize:
npx sequelize-cli db:migrate
To start the server in development mode, use the following command:
npm run dev
To start the server in development mode, use the following command:
npm run test
-
http://localhost:3000/v1/auth/generate-token
is a GET request that is used to generate tokens for authentication.The response returns a JSON object with the following schema:
{ "tokens": { "refresh": { "token": "string", "expires": "integer" }, "access": { "token": "string", "expires": "integer" } } }
-
POST /customer/register
: Registers a new customer with their name, email, and birthday.This endpoint requires a valid JWT (JSON Web Token) to be included in the
Authorization
header of the request. The token should be prefixed with "Bearer ".In Postman use access.token key of the tokens response in the token generation API like this,
Content-Type
:application/json
Authorization
:Bearer <your-token-here>
The request should include a JSON payload with the following parameters:
{ "name": "", "email": "", "birthday": "" }
The response to the request is a JSON object with the following schema:
{ "customer": { "id": 0, "name": "", "email": "", "birthday": "", "created_date_time": "", "modified_date_time": "" } }