applied-scala
Getting Started
Similar to Intro to Scala
- Skip this step if you have already done Intro to Scala on your current machine. If you're going to use IntelliJ IDEA (Community edition is fine), you need to install Java 8 even if you have a newer version of Java installed.
brew tap homebrew/cask-versions
brew cask install homebrew/cask-versions/adoptopenjdk8
- Before the course, please run the following:
git clone git@github.com:realestate-com-au/applied-scala.git
cd applied-scala
./auto/test
./auto/start-local
This should start the app. Note that the tests should be failing at this point.
- Now test this out in a new tab.
curl http://localhost:9200/movies
You should get back [{"name":"Titanic"}]
. Now press ctrl+c
in the previous tab to shut down the app.
- Open up the project in IntelliJ IDEA and make sure it all compiles. Now you're ready to go!
Open up SBT
Using Docker
./auto/sbt
or
Using portable SBT
./sbt
Run test
./auto/test
How to start app
./auto/start-local
Suggested Format
Day 1
- IO Exercises
- Http4s overview + Endpoint 1: Hello World
- Circe Exercises
- Code walkthrough: GET all movies (no exercises)
- Endpoint 2: GET movie
- Endpoint 3: GET movie?enriched=true
Day 2
- Validated Exercises
- Endpoint 4: POST movie
- Endpoint 5: POST movie/id/review
- Wrap up
Further reading
Test queries
Fetch all movies
$ curl http://localhost:9200/movies
Fetch movie
$ curl http://localhost:9200/movies/1
Fetch enriched movie
$ curl http://localhost:9200/movies/1?enriched=true
Save movie
- Successful save
$ curl -H "Accept: application/json" -X POST -d "{\"name\": \"Cars 3\", \"synopsis\": \"Great movie about cars\"}" http://localhost:9200/movies
- Validation errors
$ curl -H "Accept: application/json" -X POST -d "{\"name\": \"\", \"synopsis\": \"\"}" http://localhost:9200/movies
Save review
- Successful save
$ curl -H "Accept: application/json" -X POST -d "{\"author\": \"Jack\", \"comment\": \"Great movie huh\"}" http://localhost:9200/movies/1/reviews
- Validation errors
$ curl -H "Accept: application/json" -X POST -d "{\"author\": \"\", \"comment\": \"\"}" http://localhost:9200/movies/1/reviews