Skip to content
Subscribe to various subreddits and have top posts sent to your Pocket account.
TypeScript JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client
server
.buildpacks
.eslintrc.js
.gitignore
.prettierrc.js
.travis.yml
README.md

README.md

Subreddit Subscriber

User Stories

Key User Stories

Able to authenticate with Pocket and designate a subreddit, lookback, numEntries, and cadence of a job that will add top stories from that subreddit to my Pocket account.

Additional User Stories

  • Able to add tags to a job so that stories added under that job are tagged in Pocket.
  • Able to edit all fields (lookback, numEntries, cadence, subreddit, tags) of a job
  • Able to view summary information about a job (most of above + lastRunDate, nextRunDate)
  • Able to delete a job
  • Give it a FE so people can add their pocket API or some other input to recieve stories
  • Able to view stories on the FE that would be saved to Pocket (allowing users to forego connecting to Pocket and just using the FE)
  • Able to view links and titles of stories added by job on last run.

End-goal: Prevent me being distracted and sifting through the content

Data Model

dbo.users

  • userId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY
  • name VARCHAR(255) NOT NULL
  • email VARCHAR(255) NOT NULL
  • password VARCHAR(255) NOT NULL
  • token VARCHAR(MAX) NULL
  • pocketAccessToken VARCHAR(MAX) NULL
  • dateCreated DATETIME NOT NULL DEFAULT GETDATE()
  • dateDeleted DATETIME NULL
  • dateModified DATETIME NOT NULL DEFAULT GETDATE()

dbo.subreddits

  • subredditId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY
  • name VARCHAR(255) NOT NULL
  • dateCreated DATETIME NOT NULL DEFAULT GETDATE()
  • dateDeleted DATETIME NULL

dbo.jobs

  • jobId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY
  • subredditId INT NOT NULL FOREIGN KEY REFERENCES dbo.subreddits(subredditId)
  • userId INT NOT NULL FOREIGN KEY REFERENCES dbo.users(userId)
  • cadenceId INT NOT NULL FOREIGN KEY REFERENCES dbo.cadences(cadenceId)
  • lookbackId INT NOT NULL FOREIGN KEY REFERENCES dbo.lookbacks(lookbackId)
  • numEntries INT NOT NULL
  • dateCreated DATETIME NOT NULL DEFAULT GETDATE()
  • dateModified DATETIME NOT NULL DEFAULT GETDATE()
  • dateDeleted DATETIME NULL
  • lastRunDate DATETIME NULL
  • nextRunDate DATETIME NULL

dbo.jobTags

  • jobId INT NOT NULL FOREIGN KEY REFERENCES dbo.jobs(jobId)
  • tag VARCHAR(100) NOT NULL

dbo.cadences

  • cadenceId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY
  • name VARCHAR(20) NOT NULL

entries

  • daily
  • weekly
  • monthly

dbo.lookbacks

  • lookbackId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY
  • name VARCHAR(20) NOT NULL

Job Scheduling

At a daily cadence, there will be a cron job that iterates through all non-deleted jobs. It will execute any that do not have a lastRunDate. Once it does that, it will update their lastRunDate and calculate the nextRunDate using the associated cadence. It will also execute any that have a nextRunDate equal to the current date. After those are executed, their lastRunDate will be updated to be the currentDate, and the nextRunDate will be calculated.

When the job is executed, it will check the subredditId and numEntries. It will make a request to the Reddit API to get the top numEntries for the past lookback for the associated subreddit. It will then use the user's Pocket accessToken to send those entries to their Pocket account.

Job Creation and Display

  • jobId
    • deletable (deletes entire job)
      • upon clicking, triggers a confirmation modal
  • subredditName
    • editable
  • cadence (check every day? every week?)
    • editable
  • lookback (TOP of last week? last month?)
    • editable
  • numEntries (how many posts to add?)
    • editable
  • tags
  • lastRunDate (e.g. January 1, 2019 - 11:07am)
  • nextRunDate

There is an editing an deletion button for each row. Clicking either brings up the relevant modal.

Authentication

To store the Pocket accessToken for each user and their associated jobIds, authentication will be necessary. Users can authenticate by creating an account (email, password) or by authenticating through Google. If done through the latter, only the user's gmail will be stored and not their password.

Display

Somewhere, I want confirmation that I've authenticated with Pocket. Show me my pocket username or something.

Testing

  • job creation
  • making request to reddit api
  • making request to pocket api
  • iterating through jobs at a cadence

Migrations

Upon connection to a database, TypeORM will apply any pending migrations to set up the data model.

Database

Postgresql. This has relational data, but I want to use a database that isn't SQL server.

Backend

Nodejs on TypeScript. This is going to involve a lot of API calls but not a lot of expensive processing.

Features

  • Jobs
    • editing
    • deleting
    • creation
    • styling
  • Auth
    • local
    • cleanup
  • Pocket
    • seamless integration

Journal

  • troubleshooting passport is fucking tricky. you pretty much have to just copy a tutorial and make tweaks.
  • very glad I scaffolded a lot out and populated with Throw.notImplemented, but also annotated the types, so that it would be easy to implement
  • testing external APIs first was a good idea
  • planning out the UI first was a good idea, as well as implementing it last
You can’t perform that action at this time.