This app get tweets and save them on redis, then you can get that saved tweets by an edpoint!
- Redis
- RabbitMQ
- Access to twitter API
I installed Redis on WSL; to do that, follow the next steps
sudo apt update
sudo apt install redis-server
Confirm redis instaltion
sudo apt install redis-server
Redis version
redis-server --version
Confirm that redis is connected
redis-cli ping
I used docker to run an image, if you want follow this option run the next command
docker run -d --hostname my-rabbit -p 5672:5672 -p 8081:15672 --name some-rabbit rabbitmq:3-management
docker required
npm install
npm run dev
Inmediatly when you run the app, it will connect to twitter streaming and start listening for tweets
I give you an example of the ".env" file, you just have to add there your values, raname ".env.example" to ".env" and the app will work perfectly
By now the only way is change it manually accesing to src > server > routes > twitter.js There you will find:
const rules = [
{ 'value': 'platzi -is:retweet', 'tag': 'platzi_tweet'},
{ 'value': 'node -is:retweet', 'tag': 'node_tweet'},
{ 'value': 'open source -is:retweet', 'tag': 'open_source_tweet'}
]
You can change it or add more, and remember that you will need the tags for your gets; to create your own rules check this link
There is only one endpoint, where you can get the tweets by two options:
- Every tweet
- Tweets with your keyword
- Get every tweet; you will recive EVERY tweet that is saved in your DB.
curl -X GET -H "Content-Type: application/json" -d localhost:3000/api/
- Get only tweets that contains one of your keyword (Needs match with the "tag" that you asigned) BY NOW you have to made a get request with a body like this:
{
"tweetsAbout": "platzi_tweet"
}
to: localhost:3000/api/
Pull requests are welcome!. And if you have an idea for a feature and dont have time to do this, feel free to open a issue!
You can comment the line 17 on src > index.js and it will run only the api, without the streaming with tweeter, made it if you want to do something only with your local data 💜💜💜