Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sawyerh/twitter-hacks
Twitter API integrations to make it more useful/enjoyable.
https://github.com/sawyerh/twitter-hacks
firebase serverless twitter typescript
Last synced: 19 days ago
JSON representation
Twitter API integrations to make it more useful/enjoyable.
- Host: GitHub
- URL: https://github.com/sawyerh/twitter-hacks
- Owner: sawyerh
- Created: 2020-05-24T01:14:25.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-21T16:29:23.000Z (over 1 year ago)
- Last Synced: 2024-05-01T19:43:22.694Z (6 months ago)
- Topics: firebase, serverless, twitter, typescript
- Language: TypeScript
- Homepage: https://twitter.sawyer.soy
- Size: 986 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Overview
### Feed schedule
- 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### Delete schedule
Fires daily and deletes your Tweets and Twitter likes that are older than 14 days, and disables retweets from everyone you follow.
## Caveats
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.
## Tips
### Run in dev mode
From the root of the repo, run:
```
npm run dev
```### Watch for changes
Run `build:watch` in a Terminal or through [VS Code's "Build task" runner](https://code.visualstudio.com/docs/typescript/typescript-compiling#_step-2-run-the-typescript-build)
### Locally trigger a function
From `functions/`, run:
1. `npm run shell`
1. Call the function name:```sh
pubsub.getTweets()
``````sh
api.tweets.get('?lastId=123')
```### View logs
View detailed logs in [StackDriver](https://console.cloud.google.com/project/_/logs?service=cloudfunctions.googleapis.com&advancedFilter=resource.type%3D%22cloud_function%22%0A)
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"
```[View or create dashboards](https://console.cloud.google.com/monitoring/dashboards)
## Environment configuration
See the `set-env` script in `functions/package.json`
### Required environment keys
```js
{
"twitter": {
"access_token_key": string,
"access_token_secret": string,
"consumer_secret": string,
"consumer_key": string
"username": string
}
}
```### Set Functions environment config
```
firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"
```