Due to limitations of existing NodeJS Twitter API implementations (such as not being able to use premium search features like non-truncated text and 100+ results) some of the tweets may look incorrect due to truncated text.
You will need Twitter application credentials, as I did not upload my application credentials to github. Instructions are below in an npm script to run this project locally or you can visit http://167.99.63.15 where I've spun up a droplet to see the project in action.
To set up this project, you need to have NodeJS >= 10.0 and Yarn installed (although NPM may be used in place of Yarn, and run the simple command of yarn
or yarn install
.
The project is divided into two sections: server
and client
. The client is the base-level project, with a server directory
used to connect to the twitter API via OAuth2 and do server side object creation for the word count statistics.
- To run the server, create a new terminal instance inside the root directory, and run the following command. Due to the recommended Twitter library used, we have to declare all keys as ENV variables. This will spawn a file watcher and http server in case you would like to live-edit server code.
$ twitterConsumerKey=YOUR_CONSUMER_KEY twitterConsumerSecret=YOUR_CONSUMER_SECRET twitterAccessToken=YOUR_ACCESS_TOKEN twitterAccessTokenSecret=YOUR_ACCESS_SECRET npx nodemon server
- In a new terminal tab, pane, or instance, run the
yarn start
command to start the client in a similar live-reload server situation. This will open a new tab in your primary browser with the project.
You can toggle between the list of most used words and tweets by pressing the button in the upper right of the screen. You can also update the hashtag searched via the input at the top, this functionality is to make up for the not-so-hot design I've implemented, hopefully.
To run basic tests in Jest with a spawned watcher, run yarn test
. To generate a coverage report, run yarn test --coverage
.