A TypeLevel API Boilerplate inspired by scala-pet-store
- Http4s as the web server
- Circe for json serialization
- Doobie for database access
- Cats for FP awesomeness
- ScalaCheck for property based testing
- Circe Config for app config
- Shapeless for domain tagged types
- Tagless Final for the core domain.
-
Install PostgreSQL 9.6+
-
Initialize database (use password: "password01" as default)
cd scala-api-boilerplate
mkdir .db
initdb -D .db/api
pg_ctl -D .db/api start
createuser -d -s api -P
createdb api_local -O api
- Edit 'src/main/resources/reference.conf' to use new database settings or create an .env file and source it.
touch .env
echo 'export DB_DRIVER=org.postgresql.Driver' >> .env
echo 'export DB_URL=jdbc:postgresql://localhost:5432/api_local' >> .env
echo 'export DB_USER=api' >> .env
echo 'export DB_PASSWORD=password01' >> .env
echo 'export DB_POOL_SIZE=16' >> .env
source .env
- Start up sbt:
> sbt
- Once sbt has loaded, you can start up the application
> ~reStart
This uses revolver, which is a great way to develop and test the application. Doing things this way the application will be automatically rebuilt when you make code changes
- To stop the app in sbt, hit the
Enter
key and then type:
> reStop
Start up sbt:
> sbt
Once sbt has loaded, you can test the application
> test
In order to run the functional tests, your machine will need to have Python 3 and pip, and virtualenv.
- To install pip on a Mac, run
sudo easy_install pip
- Then install virutalenv
sudo pip install virtualenv
To test out the app, first start it up following the directions above
and doing reStart
Then, in a separate terminal, run the test suite:
cd functional_test
./run.py live_tests -v
Contributions are always welcome, no matter how large or small. Before contributing, please read the code of conduct.