Git Product home page Git Product logo

vaccination-stats's Introduction

Vaccination Stats Web API Serverless Application

This project loads a JSON file with COVID-19 vaccination stats and returns data as an AWS Lambda exposed through Amazon API Gateway.

For more information about how the Amazon.Lambda.AspNetCoreServer package works and how to extend its behavior view its README file in GitHub.

Data Source

Data is pulled directly from mattwaite's GitHub repository that updates daily with data pulled directly from the CDC API. The request to vaccination data is cached every eight hours to limit the traffic on the GitHub file. The direct url is https://raw.githubusercontent.com/mattwaite/cdc-county-vaccination-data/main/countyvaccinations.json

Configuring for API Gateway HTTP API

API Gateway supports the original REST API and the new HTTP API. In addition HTTP API supports 2 different payload formats. When using the 2.0 format the base class of LambdaEntryPoint must be Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction. For the 1.0 payload format the base class is the same as REST API which is Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction. Note: when using the AWS::Serverless::Function CloudFormation resource with an event type of HttpApi the default payload format is 2.0 so the base class of LambdaEntryPoint must be Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction.

Configuring for Application Load Balancer

To configure this project to handle requests from an Application Load Balancer instead of API Gateway change the base class of LambdaEntryPoint from Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction.

Project Files

  • serverless.template - an AWS CloudFormation Serverless Application Model template file for declaring your Serverless functions and other AWS resources
  • aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS
  • LambdaEntryPoint.cs - class that derives from Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction. The code in this file bootstraps the ASP.NET Core hosting framework. The Lambda function is defined in the base class. Change the base class to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction when using an Application Load Balancer.
  • LocalEntryPoint.cs - for local development this contains the executable Main function which bootstraps the ASP.NET Core hosting framework with Kestrel, as for typical ASP.NET Core applications.
  • Startup.cs - usual ASP.NET Core Startup class used to configure the services ASP.NET Core will use.
  • web.config - used for local development.
  • Controllers\ValuesController - example Web API controller

You may also have a test project depending on the options selected.

Here are some steps to follow from Visual Studio:

To deploy your Serverless application, right click the project in Solution Explorer and select Publish to AWS Lambda.

To view your deployed application open the Stack View window by double-clicking the stack name shown beneath the AWS CloudFormation node in the AWS Explorer tree. The Stack View also displays the root URL to your published application.

Here are some steps to follow to get started from the command line:

Once you have edited your template and code you can deploy your application using the Amazon.Lambda.Tools Global Tool from the command line.

Install Amazon.Lambda.Tools Global Tools if not already installed.

    dotnet tool install -g Amazon.Lambda.Tools

If already installed check if new version is available.

    dotnet tool update -g Amazon.Lambda.Tools

Execute unit tests

    cd "VaccinationStats.API/test/VaccinationStats.API.Tests"
    dotnet test

Deploy application

    cd "VaccinationStats.API/src/VaccinationStats.API"
    dotnet lambda deploy-serverless

vaccination-stats's People

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.