Skip to content

tomdohnal/twitter-fomo

Repository files navigation

https://twitter-fomo.vercel.app—Best WebDev Tweets

Top webdev tweets. See the most liked tweets in webdev. No mindless scrolling.

Follow me on Twitter | Check out my YouTube channel

CI status

The codebase

App

Clone the repo and run yarn && yarn dev to run it locally

The app is built using the Next.js framework. We use a combination of SSG (Static Site Generation) and ISR (Incremental Static Regeneration). The data (tweets) are fetched directly from the DB using Prisma in the getStaticProps methods. As for the components, we use the ChakraUI library.

Animations

We use a moderately heavy amount of animations. 😍 We use the react-spring. This library makes creating good looking animations a breeze. Nonetheless, it is not mainly targeted for SVG animations so there is a good amount of custom (and somewhat confusing 🙃) logic. If you are curious, you can check out my YouTube channel to learn more about it.

Fetching tweets

Tweets are scheduled to be fetched every hour by a CRON script on Heroku. The script fetches the tweets from Twitter API and puts the new ones/updates the existing ones to the Postgres database using Prisma query builder. After this is done, the script calls a Vercel webhook which triggers a new app build with the fresh data. 🌿 To build the script (from TS to JS), use the yarn backend:build-script command. To run the (built) script, run the yarn backend:run-script command.

TypeScript

We use TypeScript. We try to find a healthy balance between having in 100% type-safe 🔒 and spending too much time ⏳ sweating about weird TypeScript errors. (That's my excuse for my lack of TypeScript knowledge, haha. 🙈)

Testing

We have a similar approach to testing as to using TypeScript—trying to find a healthy balance between having a 100% test coverage and spending twice as much time writing tests rather than coding. Nevertheless, the frontend app (unlike the backend) is not tested 🙀 at the moment. This is definitely something to work on!