Skip to content

Latest commit

 

History

History
94 lines (78 loc) · 2.27 KB

README.md

File metadata and controls

94 lines (78 loc) · 2.27 KB

bike-share-api

Build Status Coverage Status

How to start development (for Mac)

Install node.js

  • Install nodebrew for controll node.js version reference
  • Use v6.10.3 that AWS Lambda supports
$ nodebrew install-binary v6.10.3
$ nodebrew use v6.10.3
$ node -v
v6.10.3

Execute npm install

$ cd bike-share-api
$ npm install

How to run unit test

We chose AVA as test framework.

$ npm test
# > ava --verbose
#
#
#  ✔ Test example
#
#  1 test passed

Try call api on your local

$ node execute-local.js ports your_bike_share_member_id your_bike_share_password 1
# => [ { ParkingEntID: 'TYO',
#        ParkingID: '10092',
#        ParkingLat: '35.658911',
#        ParkingLon: '139.792531',
#        portNameJa: 'H1-01.豊洲IHIビル前(晴海通り)',
#        portNameEn: 'H1-01.Toyosu IHI biru Mae',
#        availableCount: 3 },

Set up awscli

Install python3

See here

$ brew install python3

Download access key from IAM console for your AWS account

accessKey.csv will be downloaded

See AWS document for details.

Install awscli

$ pip install awscli
$ aws configure
# AWS Access Key ID [None]:your_access_key_id
# AWS Secret Access Key [None]:your_secret_access_key
# Default region name [None]: ap-northeast-1
# Default output format [None]:json

Install serverless framework

$ npm install -g serverless
$ sls -v
1.27.2

Init serverless project (You don't have to do this)

$ sls create --template aws-nodejs

Deploy to aws

$ sls deploy -v
# You can see endpoint URL in log

Call deployed API

$ curl -s -d '{"MemberID":"your_bike_share_member_id","Password":"your_bike_share_member_id"}' \
  https://your_endpoint.execute-api.ap-northeast-1.amazonaws.com/dev/areas/3/ports