Skip to content

Latest commit

 

History

History
108 lines (86 loc) · 3.77 KB

README.md

File metadata and controls

108 lines (86 loc) · 3.77 KB

Setup

Note:- If You have already setup JAVA_17 then skip this step

  1. Java 17 Installation on macOS
    brew tap homebrew/cask-versions
    brew install --cask temurin17
    
  2. Set JAVA_17 Env value. Follow step 2 here

How build & run this project?

Running locally

Install and run DynamoDB on your local machine:

  1. Install AWS CLI and Configure

    1. Install AWS CLI Run following commands
      • curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
      • sudo installer -pkg ./AWSCLIV2.pkg -target /
    2. To verify AWS CLI Run following commands
      • which aws
      • aws --version
    3. Configure AWS CLI
      • aws configure
        • Enter AccessKey : "local"
        • Enter SecretKey : "12345"
        • Enter region : "us-west-2"
        • Enter output : "json"
    4. Reference
  2. Install DynamoDB

    1. Download DynamoDB
    2. Extract downloaded file
    3. navigate to the directory where you extracted DynamoDBLocal.jar, and enter the following command.
      • java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
    4. Verify DynamoDB
      • aws dynamodb list-tables --endpoint-url http://localhost:8000
    5. Create table for Ad
      • aws dynamodb create-table --cli-input-json file://ads-table-definition.json --endpoint-url http://localhost:8000
    6. Reference
  3. Visualizing the DynamoDB Table data

    1. Download and Install NoSQL Workbench
    2. Open NoSQL Workbench and Setup DynamoDB local connection
      • Click on operation builder
      • Click on Add connection
      • Click on DynamoDB Local
    3. Reference

There are a few options to run the application (from more flexible to least)

  1. You can just use the SpringBoot run functionality that is default in IntelliJ or SpringTools in Eclipse.

  2. Start the service with Maven.

    mvn spring-boot:run -Dspring.profiles.active=local
  3. Package the jar file and run it

mvn clean package
java -jar ./target/ads-service-exec.jar --spring.profiles.active=local

Invoking Ads Service

You can use your favourite gRPC client (e.g. BloomRPC)

Import path in BloomRPC

img.png

Then import .proto file

img.png

Sample Ad Data

{
  "title": "Car sell",
  "description": "TOYOTA",
  "price": 300000.0,
  "owner": "Hello",
  "status": "LIVE"
}

JWT token algo

{
  "alg": "RS256",
  "typ": "JWT"
}

Use local-ads-service-public.pem to encode the token on local machine.

Use Authorization in Metadata

{"Authorization": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTczOTkyMDUsImlhdCI6MTY5NzM5NTYwNSwiaXNzIjoid3d3LmFjbWUuY29tIiwic3ViIjoiZjFlMzNhYjMtMDI3Zi00N2M1LWJiMDctOGRkOGFiMzdhMmQzIn0.cAP9Tav4VxO_JDxh7gL4AIoFVUZbeC27wwz5NYb-AY2OLss_mmFZGzgDPazmNYrw2_OyjDJqrTicffxF3kvJQiRHuljg4YOC0XgTwDo7aaLvw9DJFSPU8UAdVYEHZsD_CicOBkizNZlWeeIg8BwmxD6_KQdd454v7Kefr_uagMw6JUWHcyn8YZ68JexNtAyVv4ImEGd4QHPKoli5a2iWDRiAJKHG5LpKPE2DZw0avH4b6CJISz5jmTjRkN2357MS6Zudj9Hee35lJGEDxMND9wXIlAcju6vgMCm02KnY56JcnbD5StvZhE5nKcoU7tA0Rh6XKAI73Du4pn-6W11trQ"}

Or you can use client id test to bypass authentication on local machine

{"client-id": "test"}