abhishekbhartiind / player-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

Player API allows to perform some actions such as :

  • Sorted list of all players by rank ASC (from first to last): Demo πŸ‘‰ here
  • Get a player with a given Id : Demo πŸ‘‰ here
  • Get some players stats : Demo πŸ‘‰ here
  • Basic documentation πŸ‘‰ here

Components

This API is a simple REST API wrapped as a Lambda function, deployed on AWS using Serverless framework and Github Actions pipeline. The following components are used:

Installation

# install node dependencies
$ yarn install

Configurations

To make the API work locally, you must have an AWS account and configure a an AWS profile on your local machine ( in .aws/credentials file) to be able to access AWS ressources. Once this done, you need to install :

  • serverless framework (npm install -g serverless)
  • AWS CLI : to interact with the AWS cli. See πŸ‘‰ here

Now connect to AWS console and do the following actions

  • Create a s3 Bucket and place a JSON file containing all the players. In my case, the S3_BUCKET_NAME is equal to api-players and the S3_BUCKET_FILE_NAME is equal to player.json

Once this done, you need to create a .env at the root directory with the following Variables

  • AWS_PROFILE = Your AWS Profile
  • S3_BUCKET_NAME = api-players
  • S3_BUCKET_FILE_NAME = players.json (Or another name .json)
  • AWS_SETTING_REGION = Your AWS Region

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

# deploy for dev stage
$ serverless deploy

# deploy for prod stage
$ serverless deploy --stage prod

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Preview

App-demo App-demo App-demo

Todo

  • Add more tests cases
  • improve the documentation and the Readme

Stay in touch

License

Nest is MIT licensed.

About


Languages

Language:TypeScript 94.3%Language:JavaScript 4.9%Language:Shell 0.8%