title: Running a Node.JS background process for Twitter streaming API in Firebase
body: <p>I want to deploy a Node.JS script to Firebase that listens for new tweets using Twitter's streaming API, and then stores each tweet in the Firebase Database. How do I deploy this script and make sure that it runs 24/7?</p>
  
  <p>As an example, consider the following (simplified) code, based on NPM <a href="https://www.npmjs.com/package/twit" rel="nofollow noreferrer">Twit</a> package:</p>
  
  <pre><code>var stream = T.stream('statuses/sample')
  
  stream.on('tweet', function (tweet) {
    // write data to Firebase Database here
  })
  </code></pre>
  
  <p>I looked into <a href="https://firebase.google.com/docs/functions/" rel="nofollow noreferrer">Firebase Cloud functions</a>, but that's not what I want, because they are triggered by an event. I also saw there is <a href="https://github.com/firebase/firebase-queue" rel="nofollow noreferrer">Firebase Queue</a>, but I don't really want to queue the process: I just want it to run all the time. Is this possible currently with Firebase hosting?</p>
  
  <p>An alternative would be to create a Twitter recipe with <a href="https://ifttt.com/" rel="nofollow noreferrer">IFTTT</a> that calls a Webbook. However, I want to store tweets from many different users, so it's not a very flexible solution.</p>