Any messages posted to Metaweave.xyz will directly get posted to your Twitter account!
This application is comprised of an Express backend with a React frontend.
First, get all dependencies. In the root of the project run cd express && yarn && cd ../react && yarn && cd ..
Second, make a copy of the .env-example
file and name it .env
cp .env-example .env
. You will need to populate the different variables. Comments are given in the file to guide you through. You will need to apply to a Twitter Developer Account to create this bridge.
To run in development, you will have to
-
Add all environment variables
-
Run the react development server
cd react && yarn start
(it will run on port 8080). -
Ngrok to that port
ngrok http 8080 -host-header="localhost:8080"
. Take the Ngrok https endpoint and add it toFRONTEND_URL
environment variable. -
Run the backend server
cd express && yarn start
, it will run the server on port 3000. -
On the Twitter developer page, go to your Project > Authentication Settings > Edit. Under
Callback URL
andWebsite URL
add the Ngrok URL. -
Head over to the Ngrok URL and the frontend will show up.
To deploy to production, make sure that at some point in the deployment, you run cd react && yarn build
to get a built out optimized frontend code. The express server will then fetch the react code from the build server and send it to the requester.
An example of a heroku build process can be seen in the main package.json
in the folder root.
Don't forget to change the Twitter Developer Project Callback and Website URL with the one of your bridge!
- Create and edit the env file used by the Dockerfile:
$ cp express/.env-example express/.env-docker
- Change the value of
const apiPath
inreact/src/App.js
file to match with the backend URL (express)
$ docker-compose build
$ docker-compose up
$ docker cp express/migrations/. metaweave-twitter-bridge.psql:/root/
$ docker cp express/knexfile-docker.js metaweave-twitter-bridge.psql:/root/knexfile.js
$ docker exec -it metaweave-twitter-bridge.psql /bin/bash
# cd root
# apt update && apt install npm && npm install knex pg
# mkdir migrations
# mv 20211022195903_first_migration.js migrations
# mv 20211103145527_add_block_height.js migrations
# npx knex migrate:latest
- login:
$ psql -U postgres
- list tables:
postgres=# \dt
Init db: npx knex migrate:latest