Skip to content

y2k2mt/grouping-n

Repository files navigation

Grouping-N

A tiny API: Just shuffles the given names.

project description
mtl Sample project of http4s + doobie + cats-effect with cats-mtl
akka Sample project of Akka http + Akka (stateful) actor + persistence

Enjoy!

Setting up the project

  1. Install Java 8+
  2. Run postgresql database server (e.g. docker run --rm -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:13)
  3. Run ./sbt run to start the app
  4. Request
curl localhost:8080/grouping -H 'Content-Type: application/json' -d '{"n": 2,"members": ["1","2","3","4","5","6","7","8"]}'
  1. And response
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 126
{
  "group": {
    "groups": [
      {
        "members": [
          "8",
          "7",
          "3",
          "2"
        ]
      },
      {
        "members": [
          "5",
          "1",
          "4",
          "6"
        ]
      }
    ]
  },
  "id": "08d6277f-89aa-4da2-b2d6-627cd91fc749"
}