Manage a list of big data topics using Scala, Akka, and Akka-HTTP
- OpenJDK (8 or higher)
- sbt (current)
- (Optional, if Windows) Chocolatey package manager
choco install openjdk -y
choco install sbt -y
choco upgrade sbt -y
choco list --local
refreshenv
sbt --version
sbt scalaVersion
- In GitHub, add a new repo
- Add a default README.md
- (Optional) Add License
- Add a .gitignore using Scala template
- Clone down to your machine
- Add build.sbt
- Add project\build.properties
- Add project\plugins.sbt
- Add src\main\scala\Main.scala
- Add src\test\scala\MainSpec.scala
- Add src\main\resources\application.conf
- Add src\main\resources\logback.xml
- Add src\test\resources\application-test.conf
Add VS Code extesions:
- Scala Syntax (official)
- Scala (sbt) by LightBend
- Add dependencies to build.sbt
- Add sbt.version to project/build.properties
- In project/plugins.sbt add Scalastyle
- Open PowerShell as Admin and run
sbt scalastyleGenerateConfig
to create config file - Edit scalastyle-config.xml as desired (e.g. file header)
- Complete src/main/scala/Main.scala
- Open PowerShell as Admin and run
sbt scalastyle
- Run
sbt run
- Complete src/test/scala/MainSpec.scala
- Open PowerShell as Admin and run
sbt scalastyle
- Run
sbt test
Login to Heroku and create an app. Connect it to your GitHub repo. Enable automatic deployment.
In this repo:
- Add Procfile with web path
- Add system.properties with java.runtime.version=1.8
- Update project/plugins.sbt with sbt and sbt-native-packager
- Update build.sbt with .enablePlugins(JavaAppPackaging)
- Add scala.util.Properties to Main.scala
- Update Main port to use Heroku PORT if available, otherwise development port
- Open PowerShell as Admin and run
sbt compile stage
- https://scala-big-data-topics.herokuapp.com/
- https://scala-big-data-topics.herokuapp.com/users
- https://scala-big-data-topics.herokuapp.com/topics
Open Git Bash and post some data:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"Lexie","age":3, "countryOfResidence": "Finland"}' \
https://scala-big-data-topics.herokuapp.com/users
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"Abbie","age":19, "countryOfResidence": "Norway"}' \
https://scala-big-data-topics.herokuapp.com/users
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"Scala","value":1000, "category": "Languages"}' \
https://scala-big-data-topics.herokuapp.com/topics
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"Python","value":1000, "category": "Languages"}' \
https://scala-big-data-topics.herokuapp.com/topics
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"JavaScript","value":600, "category": "Languages"}' \
https://scala-big-data-topics.herokuapp.com/topics