ScalaConsultants / zio-scala2-quickstart.g8

A Giter8 template for a fully functional, ready to deploy ZIO-based microservice.
Creative Commons Zero v1.0 Universal
90 stars 18 forks source link
hacktoberfest scala template zio

Scala CI

zio-scala2-quickstart

A Giter8 template for a fully functional, ready to deploy microservice (or monolith - it's up to you).

This template will result in Scala 2.13.x compatible code. For Scala 3 use zio-scala3-quickstart.

Out of the box you get a set of CRUD endpoints in the framework of you choice (currently ZIO HTTP or Akka HTTP) that integrate with a PostgreSQL database (currently Slick but more coming in the near future).

Other notable integrations include:

Setting up the project

sbt new ScalaConsultants/zio-scala2-quickstart.g8
# then follow interactive process to choose project name and other parameters

Run tests

cd <project-name>
sbt test

Launch and interact

sbt run

# create an item
curl --request POST \
  --url http://localhost:8080/items \
  --header 'content-type: application/json' \
  --data '{
    "name":"BigMac",
    "price": 10.0
}'

# get all items
curl --request GET \
  --url http://localhost:8080/items

Docker image

Template provides packaging as docker image out of the box, using sbt-native-packager plugin.

To create an image, run:

sbt docker:publishLocal

This will create a docker image locally, named the same as your project is. You can run it like the following:

docker run -d -p 8080:8080 --name=<project_name> <project_name>:0.1.0-SNAPSHOT

Main components

This sample app has several key components:

Template license

Written in 2020 by Scalac Sp. z o.o.

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this template to the public domain worldwide. This template is distributed without any warranty. See http://creativecommons.org/publicdomain/zero/1.0/.