This POC API allows subscribing to a newsletter with specific "industry", "source", and "subcategory" of the news. You can subscribe to as many industries, sources and subcategories as desired.
- Install sqlite3
- Install node v22.0.0
- Clone the repository
- Navigate to the project directory and run
npm install
- Run
npm run db:migrate
to set up the database - Run
npm start
to start the server on port 3000- To start the server in development mode, run
npm run dev
- To start the server in development mode, run
To run the E2E tests, run npm test
Subscribes to the newsletter for the provided "industry", "source" and "subcategory".
curl -X POST localhost:3000/subscribe \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "industry": "tech", "source": "news", "subcategory": "new product releases"}'
{
"subscription": {
"id": 1,
"email": "[email protected]",
"industry": "tech",
"source": "news",
"subcategory": "new product releases"
}
}
Unsubscribes from the newsletter for the provided "industry", "source" and "subcategory".
curl -X POST localhost:3000/unsubscribe \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "industry": "tech", "source": "news", "subcategory": "new product releases"}'
{
"subscription": {
"id": 1,
"email": "[email protected]",
"industry": "tech",
"source": "news",
"subcategory": "new product releases"
}
}
Unsubscribes from the newsletter for all industries, sources and subcategories.
curl -X POST localhost:3000/unsubscribe_from_all \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'
{
"subscriptions": [
{
"id": 1,
"email": "[email protected]",
"industry": "tech",
"source": "news",
"subcategory": "new product releases"
},
{
"id": 2,
"email": "[email protected]",
"industry": "beauty",
"source": "news",
"subcategory": "new product releases"
}
]
}