https://github.com/agrafix/revenue-sample-app
Example Spock Project for f(by)
https://github.com/agrafix/revenue-sample-app
Last synced: about 1 month ago
JSON representation
Example Spock Project for f(by)
- Host: GitHub
- URL: https://github.com/agrafix/revenue-sample-app
- Owner: agrafix
- License: bsd-3-clause
- Created: 2015-11-26T20:22:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-27T09:21:42.000Z (over 10 years ago)
- Last Synced: 2026-03-12T04:06:17.971Z (3 months ago)
- Language: Haskell
- Size: 166 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Revenue Sample App
Small example demonstrating different features of [Spock](http://www.spock.li).
## Building
```bash
git clone https://github.com/agrafix/revenue-sample-app
stack build --pedantic
```
## Running
```bash
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:
```bash
# 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
```