This is a little AWS Lambda function I've got hooked up to a Flic button at my work's fave coffee shop.
Like all good cafes they open early, and sometimes close early - particularly when they've sold out of salads, or it's a quiet afternoon. So the Flic sits on their wall, and when they're about to close they tap it... a few doors down our office gets a Slack message and we know to come get our last coffees of the day!
To install locally:
$ yarn
As input is required to run the function, the easiest way to see it in action is to run the integration tests documented below.
Then, to install on AWS using Terraform, see infrastructure/. You can then configure a Flic button to send POST requests to your new API whenever it is pressed!
To run all tests at once:
$ yarn test
To run:
$ yarn unit-tests
Note that unit tests are yet to be written, and will currently just pass!!
To run:
$ yarn docker-tests
Integration tests require Docker. They run in lambci/lambda:nodejs6.10
(GitHub | Docker Hub).
The following environment variables must be defined on your system:
SLACK_HOOK_DEV
SNS_TOPIC_DEV
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
CI
- optional
The final CI
variable above is optional, but recommended. If set (which it is by default on Travis CI, for instance), it will cause errors to be thrown rather than returned as an API Gateway style response. If not set, tests will still 'pass', as errors will be mapped to a HTTP status code rather than thrown.
MIT.