Giter VIP home page Giter VIP logo

tiny-rebel-api's Introduction

Tiny Rebel API

A HTTP JSON API for returning beer information about Tiny Rebel bars

This uses the serverless framework to deploy a Lambda function to AWS, exposed via AWS API Gateway.

Usage:

GET $SERVER/{barLocation}/beers

Where $SERVER is the location where this is deployed, and {barLocation} is a supported bar location, i.e. cardiff or newport.

tiny-rebel-api's People

Contributors

tomseldon avatar

Watchers

 avatar

tiny-rebel-api's Issues

Add mock events

For testing functions locally (or in CI), need to provide mock data (in the form of JSON files).

Create a JSON file for the following:

  • getDrinksForBarLocation - cardiff
  • getDrinksForBarLocation - newport
  • getDrinksForAllLocations

Once done, could potentially run serverless invoke local during CI to verify they don't error.

Add CORS headers

Currently no Access-Control-Allow-Origin header is present. This stops the API being called from a webpage.

  • Add header as: "Access-Control-Allow-Origin": "*"

Store bar location against user

Currently a bar location has to be entered for each session. This would be better to change and store the user's choice so we do not have to ask them (or require they provide it) each time.

This involves:

  • Add DynamoDB resource the serverless.yml
  • On setting a bar location, store it (lots of docs available on this)
  • Possibly (probably) add in basic state machine for obtaining bar location, and moving on to available questions

Possible flows:

First time user

> Alexa, ask Tiny Rebel to suggest a drink

[check if user has provided bar location before]
[=no]

>> Should I check Cardiff or Newport?

> Cardiff

[store bar location as Cardiff]

>> You might like.... (etc.)

Returning user with set bar location

> Alexa, ask Tiny Rebel to suggest a drink

[check if user has provided bar location before]
[=yes]

>> You might like.... (etc.)

Returning user, overriding bar location in request

> Alexa, ask Tiny Rebel to suggest a drink in Newport

[check if user has provided bar location before]
[=yes (Cardiff)]

>> You might like.... (etc.)

etc.

Alexa SDK supports state flows and per-user attributes as would be required to implement this. See SDK docs.

Drink suggestion by price filter

Add support for getting a drink suggestion based on an upper limit, e.g.

Alexa, ask Tiny Rebel to suggest a beer that costs less than £4

This would involve:

  • Create new intent with "UpperPriceLimit" slot
  • Handle bar location as dialogue? Or add as custom slot, though seems that could get a bit wordy
  • Parse upper price limit into number (slot type?), and filter out all drinks where drink.price >= slot.upperPriceLimit

Drink suggestion by type filter

Add support to suggest a drink based on type, e.g.

Alexa, ask Tiny Rebel to suggest an IPA
Alexa, ask Tiny Rebel to suggest a pale ale
Alexa, ask Tiny Rebel to suggest a cider

This involves:

  • Adding new intent with DrinkType slot
  • Handling bar location (either via dialogue, or via extra slot, though that could be too wordy)
  • Filter drinks by drink type slot value. This is more complicated than drinks.dinkType === drinkTypeSlot as certain types overlap (e.g "IPA" should match "Pale Ale"). Need to think of best way of matching these.

Convert to Typescript

Originally hacked together in JS to get something working and deployed.

Convert to TS and add build step prior to deployment.

  • Refactor to TS
  • Add dist folder to gitignore
  • Add src folder to ignored deployment folder
  • Run complilation prior to deployment
  • Modify serverless.yml to point to compiled files

Rename to "tiny-rebel-web-services"

As this repo contains two services, i.e. JSON API and Alexa skill, calling it "tiny-rebel-api" no longer makes sense. "tiny-rebel-web-services" would be a better name.

  • Change repo name
  • Update README.md
  • Re-encrypt secure Travis env vars once repo name has changed

Add README.md for each service

  • Add README for API
  • Add README for Alexa skill (with sample utterances)
  • Modify top level README to link to service READMEs

Investigate memory usage and lower memory allocation if appropriate

Currently using default memory allocation of 1GB. It seems requests are using about 25MB per request, so can potentially drop this by a lot.

Needs investigation.

  • Is memory allocation per request? (Can a function instance handle multiple requests?)
  • How much memory is used by each Lambda function?
  • Does reducing memory allocation help with billing?

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.