项目作者: aames

项目描述 :
Send yourself an e-mail alert when NZTA Wellington says there's a crash on Twitter
高级语言: JavaScript
项目地址: git://github.com/aames/nzta-crash-alert.git
创建时间: 2018-05-15T01:32:55Z
项目社区:https://github.com/aames/nzta-crash-alert

开源协议:

下载


Crash Alert

Get an e-mail when NZTA Wellington mentions a crash.

Why?

So I know whether to leave work or to stay in town this afternoon.

Dependencies

  • Twitter developer account (api key)
  • Amazon AWS account (for SES to send e-mail)
  • node (developed on 6)

Setting up

Create a Twitter App account at https://developer.twitter.com/en.html

Twitter API requires 4 pieces of data:

  • A consumer key
  • A consumer secret
  • An access token
  • An access key

Running the app

The following parameters must be set as environment variables.

  1. TWITTER_CONSUMER_KEY=""
  2. TWITTER_CONSUMER_SECRET=""
  3. TWITTER_ACCESS_TOKEN=""
  4. TWITTER_ACCESS_KEY=""
  5. AWS_ACCESS_KEY_ID=""
  6. AWS_SECRET_ACCESS_KEY=""
  7. CRASHALERT_EMAIL_FROM=""
  8. CRASHALERT_EMAIL_TO=""

Don’t forget to npm install
$ npm install

$ npm start

Build and run with Docker

  1. First ensure your env vars are set locally.

    env

  2. Next, substitute them in a dockerfile with envsubst.

    cat Dockerfile | envsubst > DockerfileWithEnvVars

  3. Build with the substituted dockerfile.

    docker build -f DockerfileWithEnvVars .

  4. Run the dockerfile.

    docker run <image>

If variable substitution worked you should see:

  1. > crashalert@0.0.3 start /opt/crashalert
  2. > node server.js
  3. connection success https://stream.twitter.com/1.1/statuses/filter.json?follow=898926264