Example of a RealWorld app backend powered by Scala + http4s
Scala + http4s codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with Scala + http4s including CRUD operations, authentication, routing, pagination, and more.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
Ensure the following dependencies are installed and configured:
sbt test
to run the test suitesbt run
to run the web applicationThe app is now accessible from localhost:8080
.
To run the API spec tests with newman:
./scripts/newman/run.sh
to run the API spec testNote: Node.js 8+ and globally installed newman package are required
To package and run it as an uber-jar:
sbt stage
to package the application into a universal distribution format (at target/universal/stage/
)./target/universal/stage/bin/realworld
to run the web applicationEnsure Graal is downloaded and its binaries folder added to PATH
. The most convenient way is to use sdkman to switch between different Java SDK versions (Graal included).
sdk env
to initialise the shell session using sdkman
gu install native-image
to configure the native-image binary (incl. agent)To generate assisted configuration for native image:
java \
-agentlib:native-image-agent=config-output-dir=src/main/resources/graal/ \
-cp "target/universal/stage/lib/*" \
com.hhandoko.realworld.Application
To package and run it as a Graal native image:
native-image \
--no-server \
--class-path "target/universal/stage/lib/*" \
com.hhandoko.realworld.Application
./realworld
to run the web applicationAlternatively, some scripts are included in the repo to make it easy to download and create native image distribution (limited to Linux and macOS for now):
./scripts/graal/bin/setup.sh
to download and setup Graal../scripts/graal/bin/dist.sh
to create a native image distribution under the /dist
directory.Backend API implementation:
Please read PROGRESS for more details.
Scalameta substitutions (svm-subs) are copied over into the repository as the library has not had any updates for a while.
jwt-scala
fails (oracle/graal/#1152)We follow the "feature-branch" Git workflow.
snake_case
convention):
chore/
prefix followed by the short description, e.g. chore/do_this_chore
feature/
prefix followed by the feature name, e.g. feature/feature_name
bug/
prefix followed by the short description, e.g. bug/fix_this_bug
develop
branch with your changesPlease read CONTRIBUTING for more details.
Copyright (c) 2019-2021 Herdy Handoko
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
scala-http4s-realworld-example-app
is released under the Apache Version 2.0 License. See the LICENSE file for further details.