Giter Site home page Giter Site logo

serverless-stations's Introduction

Serverless Link Station API

Serverless API to calculate most suitable link station for a device at given point x,y.

Development

Install dependency serverless:

$ yarn install

Invoke index handler locally:

$ yarn run invoke-local

Which should result in:

{
    "statusCode": 200,
    "body": "{\"message\":\"Best link station for point 5,0 is 10,0 with power 49\",\"point\":[5,0],\"station\":[10,0,12,5,49]}"
}

data.json contains sample query parameters for local/remote invocation:

{
  "queryStringParameters": {
    "x": 5,
    "y": 0
  }
}

Deploy

Make sure you have the necessary AWS credentials and IAM policy set up for Serverless by following this guide.

In order to deploy the service run:

$ yarn run deploy

Which should result in something like this:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (68.81 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.............................
Serverless: Stack update finished...
Service Information
service: serverless-stations
stage: dev
region: eu-central-1
stack: serverless-stations-dev
api keys:
  None
endpoints:
  GET - https://XXXXXXX.execute-api.eu-central-1.amazonaws.com/dev/
functions:
  index: serverless-stations-dev-index

You can now invoke the Lambda directly:

$ yarn run invoke

or send an HTTP request directly to the endpoint using curl:

$ curl https://XXXXXXX.execute-api.eu-central-1.amazonaws.com/dev/?x=5&y=5

API documentation

Index

Calculate most suitable link station for a device at given point x,y.

  • URL

    /

  • Method:

    GET

  • URL Params

    Required:

    x=[integer] y=[integer]

  • Success Response:

    • Code: 200
      Content: {"message":"Best link station for point 5,0 is 10,0 with power 49","point":["5","0"],"station":[10,0,12,5,49]}
  • Error Response:

    • Code: 400 Bad request
      Content: {"error":"Query parameters x,y missing or invalid"}
  • Sample Call:

    $ curl https://XXXXXXX.execute-api.eu-central-1.amazonaws.com/dev/?x=5&y=5

serverless-stations's People

Contributors

msavela avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.