- Firebase Function runs on a recurring schedule to fetch the latest tweets from accounts I follow
- Firestore database stores the tweets
- Firebase Hosting serves the Next.js frontend, which queries tweets using a Firebase Function as the API endpoint
Fires daily and deletes your Tweets and Twitter likes that are older than 14 days, and disables retweets from everyone you follow.
This is the first time I've used TypeScript and CSS-in-JS, so there's probably some things not best practice happening in here.
From the root of the repo, run:
npm run dev
Run build:watch
in a Terminal or through VS Code's "Build task" runner
From functions/
, run:
-
npm run shell
-
Call the function name:
pubsub.getTweets()
api.tweets.get('?lastId=123')
View detailed logs in StackDriver
In the StackDriver Logging UI, use the advanced filter field to narrow the log scope to the function you want to analyze, then click Submit Filter to filter the logs. For example, you could analyze only logs from a single function matching a custom event:
resource.type="cloud_function"
resource.labels.function_name="CustomMetrics"
jsonPayload.event="my-event"
See the set-env
script in functions/package.json
{
"twitter": {
"access_token_key": string,
"access_token_secret": string,
"consumer_secret": string,
"consumer_key": string
"username": string
}
}
firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"