This project allows admins to add users to a list via CSV upload, efficiently handling 10,000+ records, and send email notifications to them using the provided CSV file.
-
URL:
http://localhost:3000/post
-
Method:
POST
-
Description: Creates a new list with a title and custom properties.
-
Request Body:
{ "title": "My List", "customProperties": [ { "title": "city", "fallbackValue": "Unknown" } ] }
-
Response:
- 201 Created: List created successfully.
- 400 Bad Request: Missing or invalid parameters.
- 409 Conflict: List with the same title already exists.
-
Example:
curl -X POST http://localhost:3000/post -H "Content-Type: application/json" -d '{ "title": "My List", "customProperties": [ { "title": "city", "fallbackValue": "Unknown" } ] }'
✅ List creation with title and custom properties
-
URL:
http://localhost:3000/:listTitle/users
-
Method:
POST
-
Description: Adds users to the specified list via CSV upload. The CSV must have a header row with 'name' and 'email' as required fields. Custom properties should match the headers.
-
URL Parameters:
listTitle
(string) - The title of the list to add users to.
-
Request Body: Multipart/form-data
- file: CSV file containing users to be added.
-
Sample CSV Format:
name email city John Doe [email protected] Bengaluru Jane Doe [email protected] - Note: The second record doesn't have the city value defined, so the fallback value present in the list should be used.
-
Response:
- 200 OK: Users added successfully with details.
- 400 Bad Request: Missing or invalid parameters.
- 404 Not Found: List not found.
- 409 Conflict: Duplicate emails found.
- Partial Success: Users added with some errors. The response will include details about the errors and successful additions.
-
Example:
curl -X POST http://localhost:3000/My%20List/users -H "Content-Type: multipart/form-data" -F "file=@/path/to/your/file.csv"
✅ Upload CSV file to add users to the list
- Invalid Parameters: Ensure all required parameters are included in the request body or URL.
- Unique Emails: Ensure no duplicate emails are present in the CSV file.
- List Not Found: Ensure the list title specified in the URL exists.
curl -X POST http://localhost:3000/post -H "Content-Type: application/json" -d '{
"title": "Friends List",
"customProperties": [
{ "title": "hobby", "fallbackValue": "Unknown" }
]
}'
curl -X POST http://localhost:3000/Friends%20List/users -H "Content-Type: multipart/form-data" -F "file=@/path/to/your/file.csv"
Ensure to set up the following environment variables:
AUTH_EMAIL
- The email address used for sending emails.AUTH_EMAIL_PASS
- The password or app-specific password for the email account.MONGODB_URI
- The url for mongodb.
[email protected]
AUTH_EMAIL_PASS=your-email-password
MONGODB_URI= mongoDB-url