Skip to content

hackus/Scala3Http4sFullStack

Repository files navigation

Create scala fullstack project using Scala3, Http4s, Javascript

Building the project from scratch


Server


  1. sbt new scala/scala3.g8
  2. mkdir server
  3. mv src server/

Client


npm create [email protected]

  1. -> client
  2. -> vanilla
  3. -> javascript

Deploy locally

cd client
npm install
npm run dev

Install scala-js plugin

cd client
npm install -D @scala-js/[email protected]

Implementation


build.sbt


Have used RockTheJvm example and partially IdiomaticSoft

Create common dir to keep shared code between server and client 
    upheld by -core- in build.sbt    
Configure multimodule project in build.sbt
    upheld by -root- in build.sbt    
Configure server
    upheld by -server- in build.sbt
Configure client
    upheld by -client- in build.sbt

Common


Contains common DTOs between client(javascript) and server(scala)

Client


  • Change main.js - to not be confused with ScalaJs main.js
  • Create a template page with this element
    upheld by index.html
  • Create app.js that will load the css and ScalaJs:main.js which will contain the code implemented in scala on client side therefor ScalaJs library

Server


Run

  • Important

    Start from the client because, when server is started first, client does not start.
    
  • Run Client

    npm run dev
    
  • Run Server

    sbt server/run
    
  • Refresh Client

References:

About

Create full stack scala project using Javascript, Scala, ScalaJs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages