Skip to content

Template project for full-stack Scala web development based on gRPC-web.

License

Notifications You must be signed in to change notification settings

ptrdom/play-grpc-slinky-grpcweb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play gRPC Slinky gRPC-web

This template project was the result of investigation into full-stack Scala web development experience with following requirements:

  • Compile time type safety
  • Streaming API
  • Quick hot reload in development
  • Single deployment in production

Decision to base the implementation on gRPC-Web came after testing out popular implementations of REST(autowire, endpoints4s) and GraphQL (sangria, caliban) and realisation that none of existing solutions satisfy each requirement, while gRPC's basic functionality has all the required features.

How to run

Development mode

Using sbt:

  • ~serverDev
  • ~clientDev

Using IntelliJ (tested with 2020.3):

  • Enable sbt shell for compilation.
  • Use Run/Debug configurations provided in /.run.

~serverDev starts back-end based on Play Framework in watch mode. It serves both HTTP and gRPC endpoints for front-end to consume. ~clientDev starts webpack dev server with HMR enabled for Scala.js, specifically Slinky, front-end development. After running these commands and opening localhost:9000, back-end returns index page with script definition that wires-in front-end.

Production mode

Using sbt:

  • Start sbt with production flag enabled - sbt "-Denv=prod"
  • server/docker:publishLocal

In production mode, optimized front-end bundle is packaged and stored in back-end's assets, then served with aggressive caching enabled by fingerprinting.

Slinky IntelliJ support

https://slinky.dev/docs/installation/ describes how to add support @react for macro. If documented approach fails, manual plugin installation can be done by downloading https://mvnrepository.com/artifact/me.shadaj/slinky-core-ijext .jar and manually installing it as IntelliJ plugin through Settings -> Plugins -> Install Plugin from Disk.... Tested with IntelliJ IDEA 2020.3.1 and Slinky 0.6.6.

Built on:

About

Template project for full-stack Scala web development based on gRPC-web.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published