项目作者: keithcaff

项目描述 :
Spring Boot Rest API that allows users to search for stocks and follow/unfollow stocks
高级语言: Java
项目地址: git://github.com/keithcaff/StocksApi.git
创建时间: 2020-11-07T21:26:29Z
项目社区:https://github.com/keithcaff/StocksApi

开源协议:

下载


StocksApi

About

StocksAPI allows users to

  • login to their portfolio
  • search for stocks
  • follow stocks they are interested in
  • unfollow stocks they are no longer interested in

Tech Stack:

  • Spring Boot for creating the RESTful Web Services
  • Okta as the user management store and OAuth2 authorization server
  • MongoDB as StocksApi database
  • Gradle for managing the project’s build

Endpoints

Request Method URI Body (JSON) Description
GET http://localhost:8080/stocks/search?keywords=apple - Search for stocks using keywords. Returns the best-matching symbols and market information based on keywords of your choice.
POST http://localhost:8080/user/stocks [ { “symbol”: “NKE”,”name”: “NIKE Inc.”,”region”: “United States”,”currency”: “USD”}] Creates a new set of ‘followed’ stocks for the authorized user
GET http://localhost:8080/user/stocks Gets a set of ‘followed’ stocks for the authorized user
PUT http://localhost:8080/user/stocks/{userStockId} Updates the set of ‘followed’ stocks using the userStocksId

Okta

To access the protected server, you need a valid JSON Web Token.
Details on how to set up your own Okta Authorization server and get a JWT token can be found here

To run the unit and integration tests

From root of the project
gradle:

  1. ./gradlew clean build

To run the application

Dependencies

MongoDB - The mongo daemon process needs to be running on localhost:27017. Steps on how to install with homebrew are outlined here

Config

Ensure you have set Okta oauth config values in application.yml file. Populate ‘issuer’, ‘client-id’ and ‘client-secret’ properties

  1. okta:
  2. oauth2:
  3. issuer: https://dev-8153053.okta.com/oauth2/default
  4. client-id: 1234567688
  5. client-secret: 1234567688
  1. Run the following gradle command from the root project directory:
    1. ./gradlew bootRun
  2. You can navigate to localhost:8080/ to view the home screen where you can login/create a user
  3. If you just want to invoke the rest endpoints you can get a valid token using OIDCDebugger. Details on how to get token from OIDC Debugger are outlined in this Okta blog entry here