Giter Site home page Giter Site logo

keynmol / jobby Goto Github PK

View Code? Open in Web Editor NEW
37.0 2.0 3.0 168 KB

Smithy4s (Scala + Scala.js) full-stack application

Home Page: https://blog.indoorvivants.com/tags/series:smithy4s

Scala 78.05% HTML 0.37% JavaScript 0.18% Shell 17.00% Smithy 4.40%
full-stack scala scalajs smithy smithy4s webapp

jobby's Introduction

Jobby

This is a full-stack Scala application (job posting board), made with the following excellent libraries and technologies:

  1. Scala 3
  2. Smithy4s and Smithy for the API and protocol definition between backend and frontend (and in tests)
  3. Scala.js and Laminar for the SPA frontend
  4. PostgreSQL and Skunk for database access
  5. Weaver-Test for unit and integration testing

The app used to be deployed on

  1. Platform.sh but I've run out of the free trial plan
  2. Heroku but they discontinued the free flans for everyone

and now the app is deployed to the lovely Fly.io and here's the live version

It's a companion repo for my 4-part blog post series.

Demo of the Jobby App

Prerequisites

  • JDK 11+

  • SBT installed (or use the ./sbt launcher provided)

  • PostgreSQL Easiest way to run it is:

    docker run -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=jobby -d postgres
    

    Take note of the password (mysecretpassword) and database (jobby), you will need to configure the app .

Running

To just run the app (not great for development per se), run the following command:

sbt 'app/run 9999'

Then open http://localhost:9999 - and you should see a (not working) app.

Configuration

The following settings are respected, and can be either be set as environment variables (recommended for deployments), or read from the jobby.opts file at the root of the project, for example:

PG_PASSWORD=mysecretpassword
PG_DB=jobby
LOCAL_DEPLOYMENT=true
  • PG_PASSWORD, PG_HOST, PG_DB, PG_USER, PG_PORT - variables to configure access to Postgres

  • LOCAL_DEPLOYMENT - setting this to true will disable hardened cookies for authentication, making it easier to develop locally

  • RELEASE - setting it to yesh will produce fully optimised, single-file frontend from Scala.js

Developing

This gets finicky as we try to satisfy the following requirements:

  1. Backend should be rebuilt and restarted independently of the frontend
  2. Frontend should be rebuilt on a per-module basis, and managed by https://vitejs.dev/
  3. Request to backend should be proxied

To achieve (1), we need to start the backend without bundling the frontend - removing the RELEASE env variable will achieve that:

(in terminal 1)

PG_PASSWORD=mysecretpassword PG_DB=jobby sbt '~app/reStart 9999'

To achieve (2), we need to

a) Continuously rebuilt the frontend:

(in terminal 2)

sbt '~buildFrontend'

b) Run Vite's development server:

(in terminal 3)

cd frontend-build && npm run dev

And (3) is achieved by the configuration in frontend-build/vite.config.js. Make sure to start the server on port 9999

jobby's People

Contributors

keynmol avatar keynmol-steward[bot] avatar mergify[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.