This is a Node.js API built with Express to manage contact messages sent through a portfolio. The API includes features for listing, searching, and creating messages, as well as sending email notifications using Nodemailer.
- List contact messages: Endpoint to retrieve all sent messages.
- Search message by ID: Endpoint to find a specific message by its unique identifier.
- Create contact message: Endpoint to save a new message in the database and send an email notification.
- Email sending: Integration with Gmail via Nodemailer for notifications.
- Node.js
- Express
- Sequelize (Database ORM)
- Nodemailer (Email sending)
- dotenv (Environment variables management)
- CORS (Cross-origin resource sharing)
-
Clone the repository:
git clone https://github.com/ImFelipeOliveira/contact-api.git
-
Install dependencies:
npm install
-
Configure environment variables in
.envfile:CORSALLOWED=http://localhost:5173/ SMTPEMAIL=seuemail@gmail.com SMTPPASSWORD=suasenha FROMEMAIL=destinatario@gmail.com APIKEY=change-me
-
Start the server:
npm start
-
Access the API endpoints at
http://localhost:3000
GET /contact- Returns all contact messagesGET /contact/:id- Returns a specific message by IDPOST /contact- Creates a new message and sends an email notification
Contributions are welcome! Feel free to open issues or submit pull requests.