RedditNotifier/
├── api/
├── node_modules/
├── .gitignore
├── database.js
├── package-lock.json
├── package.json
├── README.md
├── server.ks
└── .env 👈🏻
.env
SENDGRID_API_KEY=your-api-key-without-single-or-double-quotes
npm install
npm run dev
RedditNotifier | status: up | port: 8000
A newsletter is only sent when a user has at least one subreddit and if the isNewsletterEnabled
is set to true.
Inside server.js
you will find the scheduler that sends out an email every day at 8am for each existing user.
You can change the argument for the scheduler from:
...
const job = schedule.scheduleJob(rule, function() {
...
}
...
to the following:
...
const job = schedule.scheduleJob('*/30 * * * * *', function() {
...
}
in order to trigger an email every 30 seconds.
CREATE
Method: POST
Endpoint: localhost:8000/user
Data:
{
"username": "Alex Martin",
"email": "[email protected]",
"isNewsletterEnabled": true
}
LIST
Method: GET
Endpoint: localhost:8000/user/list
Data: not needed.
FIND
Method: GET
Endpoint: localhost:8000/user/1
Data: User ID in the url
DELETE
Method: DELETE
Endpoint: localhost:8000/user/1
Data: User ID in the url
UPDATE
Method: PATCH
Endpoint: localhost:8000/user/1
Data: User ID in the url
{
"username": "Chad Pennington",
"email": "[email protected]",
"isNewsletterEnabled": false
}
CREATE
Method: POST
Endpoint: localhost:8000/user/1/subreddit
Data: User ID in the url
{
"name": "smashbros",
"category": "game"
}
UPDATE
Method: PATCH
Endpoint: localhost:8000/user/1/subreddit/1
Data: User ID in the url. Subreddit ID in the url.
{
"name": "smashbrosultimate",
"category": "game"
}