Skip to content

alsnrbernardo/fsharp-web-server-showcase

Repository files navigation

Scoring-API

POC API for scoring CPFs based on F# (Dotnet 6) and the Saturn Framework.

Frameworks/Libraries

Setting the application up (from scratch)

docker run --name db-pgsql -e POSTGRES_PASSWORD=passw0rd -p 5432:5432 -d postgres
git clone https://github.com/alsnrbernardo/score-api.git && cd score-api
  • Set up the dependencies
dotnet tool restore && dotnet paket install
  • Build the solution
dotnet build .
  • Perform database migration (depends on Postgres container)
dotnet run --project src/Migrations
dotnet run --project src/Scoring-API

Testing

API endpoints:

  • GET /health check if the server is running.
curl --request GET \
--url http://localhost:8085/health
  • GET /score/<CPF> fetches the values and creation dates of scores attributed to the given CPF.
curl --request GET \
--url http://localhost:8085/score/xxxxxxxxxxx \
--header 'Content-Type: application/json'
  • POST /score scores and registers the provided CPF
curl --request POST \
--url http://localhost:8085/score \
--header 'Content-Type: application/json' \
--data '{ "cpf": "xxxxxxxxxxx" }}'