A cash register web service
Build and start the service (on port 8080 by default):
./gradlew build && java -jar build/libs/cash-register-0.0.1.jar
- Couchbase connection string:
cb.conn
(default iscouchbase://localhost
) - Couchbase bucket name:
cb.bucket
(default iscash-register
) - Couchbase password:
cb.password
(default iscash-register-123
) - Maximum order number:
order.num.max
(default is 100)
Spring looks for the configuration file application.properties
in the current directory or a config
directory within the current directory.
To run a Couchbase server in a Docker container:
docker pull couchbase/server
docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase
The server will be accessible via HTTP at http://localhost:8091
or from the console via docker exec -it db sh
.
The file src/test/resources/items.n1ql
contains queries to populate a bucket with items.
curl localhost:8080/items
curl -XPOST localhost:8080/orders -d'{"tax":0.09}' -H"Content-Type: application/json"
curl -XPOST localhost:8080/orders/$ORDER_ID -d'{"item_id":1}' -H"Content-Type: application/json"
curl -XPUT localhost:8080/orders/$ORDER_ID -d'{"item_id":1,"amount":2}' -H"Content-Type: application/json"
curl -XDELETE localhost:8080/orders/$ORDER_ID -d'{"item_id":1}' -H"Content-Type: application/json"
curl -XPOST localhost:8080/orders/$ORDER_ID/submit
curl -XPOST localhost:8080/tender -d'{"order_id":"'$ORDER_ID'","amount":1899,"method":"CASH"}' -H"Content-Type: application/json"