/revenue-sample-app

Example Spock Project for f(by)

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Revenue Sample App

Small example demonstrating different features of Spock.

Building

git clone https://github.com/agrafix/revenue-sample-app
stack build --pedantic

Running

stack exec revenue-app
# on different terminal
sqlite3 -init sample-data.sql database.sql
[Ctrl+C]

Try it out

  • Visit http://localhost:3000 in our browser
  • Login with admin and admin1.
  • Extract the value of the cookie spockcookie
  • Try the rest api:
# should fail
curl -v --cookie "spockcookie=[COOKIE_VALUE_HERE]" -d '{"name": "Foo", "price": -1, "revenue": 5}' -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:3000/api/item/create

# should succeed
curl -v --cookie "spockcookie=[COOKIE_VALUE_HERE]" -d '{"name": "FooBar", "price": 5.00, "revenue": 0.05}' -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:3000/api/item/create