Skip to content

Emails a user the top 3 posts on their favorite subreddits.

License

Notifications You must be signed in to change notification settings

alexgmartin/reddit-digest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

1. Create a .env file at the root of the project:

RedditNotifier/
├── api/
├── node_modules/
├── .gitignore
├── database.js
├── package-lock.json
├── package.json
├── README.md
├── server.ks
└── .env 👈🏻

2. Add the SendGrid API Key to it:

.env

SENDGRID_API_KEY=your-api-key-without-single-or-double-quotes

3. Install + Run the project:

npm install
npm run dev

4. You should be up and running 🥳

RedditNotifier | status: up | port: 8000

Email Newsletter

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.


API Endpoints


User


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
}

Subreddit


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"
}

About

Emails a user the top 3 posts on their favorite subreddits.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published