/aws-lambda-whereis

Primary LanguageJavaScriptMIT LicenseMIT

aws-lamba-whereis

Build Status codecov

⚠️ work in progress with webpack / es6

Quick start

Prerequisites

  • node, npm or yarn
  • serverless : $ npm install -g serverless
  • what3words API key : register
  • opencagedata API key : register
  • google API key : register

AWS - Credentials

To deploy; an AWS account is needed, AWS lambda is available with the free tier account for 12 months : https://aws.amazon.com/lambda/pricing/

Watch the video on setting up credentials

or look at serverless documentation about credentials

Adding a profile on the AWS config

$ serverless config credentials --provider aws --key <YOUR-AWS-KEY> --secret <YOUR-AWS-SECRET> --profile <namedProfile>

Clone the repo

$ git clone https://github.com/tsamaya/aws-lambda-whereis.git

$ cd aws-lambda-whereis

Setup

$ npm i

create environment.yml file

$ serverless env --attribute GOOGLE_API_KEY --value <YOUR-GOOGLE-API-KEY> --stage dev

$ serverless env --attribute W3W_API_KEY --value <YOUR-W3W-API-KEY> --stage dev

$ serverless env --attribute OPCD_API_KEY --value <YOUR-OPEN-CAGE-DATA-API-KEY> --stage dev

create .env file

$ serverless env generate

Running locally

$ sls offline start

or

$ npm start

sunny tests

$ curl "http://localhost:3000/whereis?lat=40.714224&lng=-73.961452"

$ curl "http://localhost:3000/whereis?addr=index.home.raft"

rainy tests

$ curl "http://localhost:3000/whereis"

$ curl "http://localhost:3000/whereis?lat=40.714224"

$ curl "http://localhost:3000/whereis?lat=aa&lng=bb"

$ curl "http://localhost:3000/whereis?addr=aa.bb.cc"

deploy

$ sls --aws-profile <namedProfile> --stage <stage> deploy

display logs

$ sls --aws-profile <namedProfile> --stage <stage> logs -f whereIs -t

Unit tests and coverage

$ npm test

$ npm run coverage

Revision history

1.1.0 TBD ES6 and webpack rework, keep one function 1.0.0 06/12/2017 Creation with 2 functions

Resources

Licensing

Licensed under the MIT License

A copy of the license is available in the repository's LICENSE file.