This API, built with Express and MongoDB, supports operations for managing leads, campaigns, and generating reports. It also includes mock endpoints to simulate a CRM API for testing purposes.
Ensure you have the following installed:
- Node.js
- MongoDB
- A
.env
file configured with the necessary environment variables
-
Clone the repository:
git clone <repository_url> cd <repository_folder>
-
Install dependencies:
npm install
-
Set up MongoDB and configure environment variables.
Create a .env
file in the root directory with the following variables:
PORT=3000 # Server port (default: 3000)
DB_URI=mongodb://<username>:<password>@<host>:<port>/<database>
EMAIL_USER=<email_user> # (Optional) Email username for logging
EMAIL_PASS=<email_pass> # (Optional) Email password for logging
EMAIL_RECIVER=<email_user> # (Optional) Report reciveing email
ETL_RUN_FREQUENCY=<hours> # For example, how often the ETL should run (if applicable)
Start the server:
npm start
Or, if you’re using nodemon
for development:
npm run dev
The server will be running on http://localhost:<PORT>
.
Base URL: /api/campaigns
Method | Endpoint | Description |
---|---|---|
GET | / |
Retrieve all campaigns |
Example:
GET http://localhost:<PORT>/api/campaigns
Base URL: /api/leads
Method | Endpoint | Description |
---|---|---|
GET | / |
Retrieve all leads |
POST | / |
Add a new lead |
Example:
POST http://localhost:<PORT>/api/leads
Content-Type: application/json
{
"name": "New Lead",
"email": "lead@example.com"
}
Base URL: /api
Method | Endpoint | Description |
---|---|---|
GET | /crm/leads |
Get a list of dummy leads |
GET | /crm/campaigns |
Get a list of dummy campaigns |
Example:
GET http://localhost:<PORT>/api/crm/leads
Base URL: /api/reports
Method | Endpoint | Description |
---|---|---|
GET | /pdf |
Generate and retrieve PDF |
Example:
GET http://localhost:<PORT>/api/reports/pdf
- The ETL process starts automatically upon MongoDB connection.
- Logging: Sensitive data logs (
EMAIL_USER
andEMAIL_PASS
) are used here for environment testing; remove or secure them in production.
Contributions are welcome!