Git Product home page Git Product logo

bolero's People

Contributors

scozv avatar

Stargazers

 avatar

Watchers

 avatar

bolero's Issues

Uniform Response or Not

Bolero recommends an uniform HTTP Response design, that is all HTTP Response will be formatted as:

{
  ok: Boolean,
  data: T
  error: String
}

see

app/controllers/CanResponse.scala
app/models/interop/HTTPResponse.scala

script for initial usage

need to add a script:

  • download the master-zip
  • read a name
  • replace all bolero to name
  • regenerate playGenerateSecret

Demo of Transaction Service

Overview

The codes for challenge assignment are written within 3 consecutive day.
Percisely, they are started from Sep 3, 08:47 to Sep 4, 19:46. (see picture below)

The codes written before Sep 3, 08:47
are extracted from my SJTU project of last year
as a RESTful Code Template named Bolero.

Read more about Bolero from my posts:

The codes in test/WithApplication.scala are copied from Play! 2.3
in order to make the Specs2 tests of Play! 2.3 even when I upgraded
project to Play! 2.4.

Branches and Deployments

I created 2 solutions for code challenge: liq-v1 and liq-v2.

They are corresponding to the branches (see picture below):

feature/liq-v1
feature/liq-v2

and to the deployments:

liq-v1.cloudapp.net
liq-v2.cloudapp.net

liq-v1 works as expected as the challenage assignment.

I prefer to liq-v2 that has 2 major differents from liq-v1:

  • Uniform HTTP Response (see issue #4),
  • transaction_id is String not Long (see issue #5)

RESTful API of liq-v2

Transaction model (tx for short) is defined as:

{
  _id: String, amount: Double, type: String, pranrent_id: String
}

GET /transactionservice/transaction

Lists all tx data (generated by activator test).

HTTP Response:

{
  ok: true,
  data: List[Transaction],
  error: ""
}

PUT /transactionservice/transaction/:id

Creates tx.

HTTP Payload data is Transaction.

HTTP Response:

{
  ok: true,
  data: Transaction
  error: ""
}

error Response will be returned when PUT duplicated _id.

GET /transactionservice/transaction/:id

Gets a specific tx data.

HTTP Response:

{
  ok: true,
  data: Transaction,
  error: ""
}

NOT_FOUND Response will be returned if _id is not existed, such as:

{"ok":false,"error":"201","data":"not found record in MongoDB from GET /transactionservice/transaction/1024"}

GET /transactionservice/types/:type

Lists the transaction_id of specific type.
If :type is not existed, empty array will be returned.

HTTP Response:

{
  ok: true,
  data: List[String],
  error: ""
}

GET /transactionservice/sum/:id

Gets the total amount of related tx data.
If :id is not existed, 0 will be returned.

HTTP Response:

{
  ok: true,
  data: Double,
  error: ""
}

Commit Tree

Image of commit tree

_id as String or Long

I prefer to String _id other than Numeric _id, because:

  • String _id contains A, B ... that can be used as the categories,
  • We can apply RegEx on String _id, especially when we are using MongoDB

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.