Send yourself an e-mail alert when NZTA Wellington says there's a crash on Twitter
Get an e-mail when NZTA Wellington mentions a crash.
So I know whether to leave work or to stay in town this afternoon.
Create a Twitter App account at https://developer.twitter.com/en.html
Twitter API requires 4 pieces of data:
The following parameters must be set as environment variables.
TWITTER_CONSUMER_KEY=""
TWITTER_CONSUMER_SECRET=""
TWITTER_ACCESS_TOKEN=""
TWITTER_ACCESS_KEY=""
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
CRASHALERT_EMAIL_FROM=""
CRASHALERT_EMAIL_TO=""
Don’t forget to npm install$ npm install
$ npm start
First ensure your env vars are set locally.
env
Next, substitute them in a dockerfile with envsubst
.
cat Dockerfile | envsubst > DockerfileWithEnvVars
Build with the substituted dockerfile.
docker build -f DockerfileWithEnvVars .
Run the dockerfile.
docker run <image>
If variable substitution worked you should see:
> crashalert@0.0.3 start /opt/crashalert
> node server.js
connection success https://stream.twitter.com/1.1/statuses/filter.json?follow=898926264