Git Product home page Git Product logo

bestsellers's Introduction

BestSellers

Get the ten best sellers books on Amazon using aws serverless environment

Description

This project works with a NodeJS lambda function running on AWS using the traditional Serverless Framework. Once deployed, you got access by GET event to a function that returns an array with the top ten best-sellers books of Amazon on that day. Another function deployed makes the scraping info once a day, triggered in a cron-like manner. The scraper function saves the information on DynamoDB, thus making the information available for the first lambda. For details about configuration of serverless, please refer to our documentation.

Deployment

In order to deploy, you need to run the following command:

Test:

$ serverless deploy --stage qa

Production:

$ serverless deploy --stage prod

After running deploy, you should see output similar to:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Installing dependencies for custom CloudFormation resources...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
........
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service BestSellers.zip file to S3 (53.14 MB)...
Serverless: Uploading custom CloudFormation resources...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...........................................................................
Serverless: Stack update finished...
Service Information
service: BestSellers
stage: prod
region: us-east-1
stack: BestSellers-prod
resources: 26
api keys:
  None
endpoints:
  GET - https://99999999.execute-api.us-east-1.amazonaws.com/prod/todaylist
functions:
  scraping: BestSellers-prod-scraping
  getTodayList: BestSellers-prod-getTodayList
layers:
  None
Serverless: Publishing service to the Serverless Dashboard...
Serverless: Successfully published your service to the Serverless Dashboard: https://app.serverless.com/xxxxx/apps/bestsellers/BestSellers/prod/us-east-1

Invocation

After successful deployment, you can invoke the scraping function by using the following command:

serverless invoke --function scraping

Which should result in response similar to the following:

{
  "statusCode": 200,
  "body": "Itens created with success!"
}

Local development

You can invoke your function locally by using the following command:

serverless invoke local --function getTodayList

Which should result in response similar to the following:

{
    "statusCode": 200,
    "body": "[
      {\"rating\":\"4.8 out of 5 stars\",\"ranking\":\"#7\",\"createdAt\":\"Mon Nov 08 2021\",\"writer\":\"Adam Wallace\",\"price\":\"$7.58\",\"title\":\"How to Catch a Turkey\"},
    ...
    ]"
}

bestsellers's People

Contributors

mcesarpl avatar

Watchers

James Cloos 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.