Development
BOX is completely written in Scala (Scala and Scala.js).
To extend the user interface a widgets system is in place
Local server
sbt server/run
Serve task compiles both client (with fastOptJS) and server then starts the server
In order to continuously reload the UI changes and take advantage of webpack fast reloading devServer, enable devServer
on the application.conf
devServer = true
be careful to enable it only in dev environment.
Enable the dev server with
sbt client/fastOptJS::startWebpackDevServer
doing so the compiled UI JavaScript are served through webpack devServer on port 8888.
Then set up the autocompile of the UI
~client/fastOptJS
that way every time a file is saved it get compilated and served on 8888.
Please note that there is no autoreload set up so you must reload the page manually on the browser.
When using devServer
the client is no more needed on the server so to by setting the env variable DEV_SERVER
disables compiling and FullOptimising.
Pre generation of Table entities
running sbt server/slick
tables files are generated so they are compiled only once, modification on database are ignored.
To delete the generate tables run sbt server/deleteSlick
Modules
- codegen: Code generation from postgres database using slick codegen library
- server: Akka-Http REST server exposing tables of the db
- client: Web UI for the REST APIs
- shared: Shared code between client and server, not all the libraries used here must be compatible with both scala JVM and Scala.js
Libraries
Knows Issues
If on compile time StackOverflow
errors appears use the following parameters:
sbt -J-Xmx4G -J-XX:MaxMetaspaceSize=1G -J-XX:MaxPermSize=1G -J-XX:+CMSClassUnloadingEnabled -J-Xss3m serve
Client
Js dependency management
JavaScript dependencies are managed using webpack npm and https://scalablytyped.org. Js dependency are injected in the bundle by webpack, if some css file is needed the library need to be exposed and loaded manually (this could be improved)
Testing
Server
We use testcontainer for testing, so you need docker installed in your machine and the user running the tests should be able to create containers.
In linux if you get Permission error you may want open the socket (WARNING THAT HAS SOME IMPORTANT SECURITY DRAWBACK)
sudo chmod 666 /var/run/docker.sock
Client
We use jsdom node.js implementation of the DOM, so you need to have node.js installed and jsdom:
npm install jsdom