Build status for master branch
This app can be used to manage Task
s in a todo list
- It is a basic REST micro-service.
- It abstracts CRUD operations on a database (in this case PostgreSQL)
- It can be run standalone using a web browser and CURL
- or it can receive web service calls from a web frontend. This is a good idea as it separates the web frontend from being able to directly access the database.
- Akka actors for lightweight, event-driven concurrent entities
- Spray HTTPX higher-level logic for working with HTTP messages, which is not specific to the server-side (spray-routing)
- Spray Routing DSL for defining RESTful web services
- Play JSON de/serialization
- Slick Functional Relational Mapping for Scala
- PostgreSQL database
- ScalaTest testing framework
- Travis CI build server. The file
.travis.yml
contains the settings for the build server. Currently PostgreSQL 9.1, 9.2 and 9.3 are supported.
-
JDK 1.7.51 or 1.8 must be installed
-
Install SBT. The [current documentation][install-sbt] suggests:
Mac:
- Install Homebrew
- Get the latest updates
brew update
- Install using brew
brew install sbt
-
Install PostgreSQL (source):
Mac:
- Install using brew
brew install PostgreSQL
- Create/Upgrade a database
initdb /usr/local/var/postgres -E utf8
- Install using brew
-
Optional - Install Lunchy. Lunchy is a tool that allows you to easily start and stop the Postgres service, but you may prefer using a PostgreSQL command.
-
Start the database service:
Lunchy:
lunchy start postgres
-
Create a PostgreSQL database for the user (see stackoverflow answer)
The file application.conf
specifies the values for:
- Micro-service:
- port (currently
3000
) - url (currently
localhost
)
- port (currently
- Database settings:
- port (currently
5432
) - database name
- username
- default password
- port (currently
The following examples assume the application.conf
file is configures the app to run on localhost on port 3000:
-
GET
As a REST web service, you can perform any of the GET actions through a web browser or through CURL:
- Count number of entries in Tasks table:
http://localhost:3000/api/v1/tasks/count
- List all tasks in the Tasks table:
http://localhost:3000/api/v1/tasks/
-
POST
Sending data to the micro-service can be performed by using CURL to a POST route:
- Create the task "Buy milk" with assignee "Me":
curl -i -H "Content-Type:application/json" -d '{"content":"Buy milk", "assignee":"Me"}' http://localhost:3000/api/v1/tasks/