Coder Social home page Coder Social logo

finn-log-pose's Introduction

finn-log-pose

A broker service that receives and forwards all incoming requests.

Project Design

The broker is using the external package Chi for routing and middle ware.

Project Breakdown

The broker system first authenticates all incoming requests to check if they are valid.

If they are, the request is than forwarded to the proper microservice if the incoming request is valid.

API Docs

Get Balance /balance/{user}

The get balance function allows you to get the balance for a user. This balance is a sum of all transaction records that exist for a user.

To utilize this function send an HTTP GET request to the server route "/balance/{user}" where {user} is the current users username. This will return a response in the format:

{
  Error bool
  Message string
  Data float32
}

where Error represents if an error has occurred, Message represents a server message describing what has occurred in the backend, and Data represents the current user's balance.

Currently, the getBalance function has not implemented token checks (unauthed users can check balances for all users.) Token checks will be added in the future to restrict global access.

Update Balance

The get balance function allows you to update the balance for a user. This function will create a new transaction in the transaction table.

To utilize this function send an HTTP POST request to the server route "/balance/{user}" where {user} is the current users username, and a json BODY in the format

{
  "transactionData": n
}

where n represents a float number. A negative number will decrement the total balance where a positive number will increment the balance. A user's balance can not fall below zero, ex: if a user has a balance of 1000, sending a value of -10000 as transactionData will throw an error.

This will return a response in the format:

{
  Error bool
  Message string
  Data float32
}

where Error represents if an error has occurred, Message represents a server message describing what has occurred in the backend, and Data represents the current user's new balance.

Currently, the getBalance function has not implemented token checks (unauthed users can check balances for all users.) Token checks will be added in the future to restrict global access.

Get all transactions

The get all transactions function allows a user to get all the transactional data for their account.

To utilize this function send an HTTP POST request to the server route "/transaction/{user}" where {user} is the current users username

This will return a response in the format:

{
  Error bool
  Message string
  Data []Transaction
}

where Error represents if an error has occurred, Message represents a server message describing what has happened on the server side, and Data represents a list of transactions in the type of the following:

type Transaction struct {
	TransactionID          int     `json:"-"`
	UserID                 string  `json:"id"`
	TransactionAmount      float32 `json:"transactionAmount"`
	TransactionName        string  `json:"transactionName"`
	TransactionDescription string  `json:"transactionDescription"`
}

Currently, the getBalance function has not implemented token checks (unauthed users can check balances for all users.) Token checks will be added in the future to restrict global access.

finn-log-pose's People

Contributors

see-air-uh avatar rogerganesh avatar

Stargazers

Melanie Le avatar  avatar

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.