Giter Site home page Giter Site logo

denisecase / scala-big-data-topics Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 3.0 25 KB

Manage a list of big data topics using Scala, Akka, and HTTP

Home Page: https://scala-big-data-topics.herokuapp.com/

License: Apache License 2.0

Scala 100.00%
scala sbt akka akka-http scalatest scalastyle rest-api heroku

scala-big-data-topics's Introduction

scala-big-data-topics

Manage a list of big data topics using Scala, Akka, and Akka-HTTP

Links

Prerequisities

  • 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

Creating From Scratch

Initialize a new repo

  1. In GitHub, add a new repo
  2. Add a default README.md
  3. (Optional) Add License
  4. Add a .gitignore using Scala template
  5. Clone down to your machine

Create standard Scala project

  1. Add build.sbt
  2. Add project\build.properties
  3. Add project\plugins.sbt
  4. Add src\main\scala\Main.scala
  5. Add src\test\scala\MainSpec.scala
  6. Add src\main\resources\application.conf
  7. Add src\main\resources\logback.xml
  8. Add src\test\resources\application-test.conf

Add VS Code extesions:

  • Scala Syntax (official)
  • Scala (sbt) by LightBend

Add dependencies and static analysis

  1. Add dependencies to build.sbt
  2. Add sbt.version to project/build.properties
  3. In project/plugins.sbt add Scalastyle
  4. Open PowerShell as Admin and run sbt scalastyleGenerateConfig to create config file
  5. Edit scalastyle-config.xml as desired (e.g. file header)

Create the first route in Main.scala

  1. Complete src/main/scala/Main.scala
  2. Open PowerShell as Admin and run sbt scalastyle
  3. Run sbt run

Create the first test in MainSpec.scala

  1. Complete src/test/scala/MainSpec.scala
  2. Open PowerShell as Admin and run sbt scalastyle
  3. Run sbt test

Publish with Heroku

Login to Heroku and create an app. Connect it to your GitHub repo. Enable automatic deployment.

In this repo:

  1. Add Procfile with web path
  2. Add system.properties with java.runtime.version=1.8
  3. Update project/plugins.sbt with sbt and sbt-native-packager
  4. Update build.sbt with .enablePlugins(JavaAppPackaging)
  5. Add scala.util.Properties to Main.scala
  6. Update Main port to use Heroku PORT if available, otherwise development port
  7. Open PowerShell as Admin and run sbt compile stage

Check Endpoints

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

Resources

  1. sbt
  2. Akka
  3. Akka docs
  4. akkahttp-quickstart
  5. ScalaTest
  6. Scala on Command Line
  7. Akka HTTP Quickstart
  8. Scalastyle
  9. Logging
  10. StackOverflow - multiple routes
  11. Scastie formatter
  12. Deploy to Heroku

scala-big-data-topics's People

Contributors

denisecase avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.