Skip to content

wjlow/applied-scala

 
 

Repository files navigation

applied-scala

Build Status

Getting Started

Similar to Intro to Scala

  1. 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 install homebrew/cask-versions/adoptopenjdk8
  1. Before the course, please run the following:
git clone git@github.com:wjlow/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.

  1. 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.

  1. 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

Schedule

Day 1

Time Topic/Exercise
9.15 🎤 Day 1 Intro and IO presentation
10.00 Morning break
10.15 IO Exercises
11.15 💻 Intro to Http4s (Presentation)
12.00 Lunch
13.00 Circe Exercises
14.00 Code walkthrough: GET all movies (no exercises)
14.30 💻 Endpoint Ex.1: GET movie
15.30 Afternoon break
15.45 💻 Endpoint Ex.2: GET movie?enriched=true
17.00 End

Day 2

Time Topic/Exercise
9.15 🎤 Day 2 Intro
10.00 Morning break
10.15 Validated and Traverse Theory (Presentation)
11.15 Validated Exercises
12.15 Lunch
13.15 💻 Endpoint Ex.3: POST movie
14.45 Afternoon break
15.00 💻 Endpoint Ex.4: POST movie/id/review
16:15 🎤 Wrap-up + Endpoint Ex.2 revisited (w/ Traverse)
16:45 End

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

  1. Successful save
$ curl -H "Accept: application/json" -X POST -d "{\"name\": \"Cars 3\", \"synopsis\": \"Great movie about cars\"}" http://localhost:9200/movies
  1. Validation errors
$ curl -H "Accept: application/json" -X POST -d "{\"name\": \"\", \"synopsis\": \"\"}" http://localhost:9200/movies

Save review

  1. Successful save
$ curl -H "Accept: application/json"  -X POST -d "{\"author\": \"Jack\", \"comment\": \"Great movie huh\"}" http://localhost:9200/movies/1/reviews
  1. Validation errors
$ curl -H "Accept: application/json"  -X POST -d "{\"author\": \"\", \"comment\": \"\"}" http://localhost:9200/movies/1/reviews

About

A series of exercises to apply your Scala knowledge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 78.3%
  • Shell 21.7%