Skip to content

Commit

Permalink
Rewriting the backend to use tapir/http4s/doobie
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Jul 10, 2019
1 parent 99762fc commit cad2707
Show file tree
Hide file tree
Showing 135 changed files with 2,443 additions and 3,056 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -5,5 +5,4 @@
target/
*.log
.DS_Store
application.conf
data/
data/
11 changes: 2 additions & 9 deletions .scalafmt.conf
@@ -1,9 +1,2 @@
style = defaultWithAlign
maxColumn = 120
align.openParenCallSite = false
align.openParenDefnSite = false
danglingParentheses = true

rewrite.rules = [RedundantBraces, RedundantParens, SortImports, PreferCurlyFors]
rewrite.redundantBraces.includeUnitMethods = true
rewrite.redundantBraces.stringInterpolation = true
version = 2.0.0-RC8
maxColumn = 140
28 changes: 15 additions & 13 deletions .travis.yml
@@ -1,23 +1,25 @@
language: scala
scala:
- 2.11.8
- 2.12.4

jdk:
- oraclejdk8

sudo: false
scala:
- 2.12.8

before_cache:
# Tricks to avoid unnecessary cache updates
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete

- du -h -d 1 $HOME/.ivy2/
- du -h -d 2 $HOME/.sbt/
- du -h -d 4 $HOME/.coursier/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
- find $HOME/.coursier/cache -name "*.lock" -type f -delete
cache:
directories:
- $HOME/.sbt/1.0
- $HOME/.sbt/boot/scala*
- $HOME/.sbt/cache
- $HOME/.sbt/launchers
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
- $HOME/.coursier
- ui/node_modules
-
env:
- TRAVIS_NODE_VERSION="5"

Expand All @@ -27,4 +29,4 @@ install:
- (cd ui;npm install)

script:
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M test
- sbt ++$TRAVIS_SCALA_VERSION test
1 change: 0 additions & 1 deletion README.md
@@ -1,7 +1,6 @@
# Bootzooka

[![Build Status](https://travis-ci.org/softwaremill/bootzooka.svg?branch=master)](https://travis-ci.org/softwaremill/bootzooka)
[![Dependencies](https://app.updateimpact.com/badge/634276070333485056/bootzooka.svg?config=compile)](https://app.updateimpact.com/latest/634276070333485056/bootzooka)

Bootzooka is a simple application scaffolding project to allow quick start of development for modern web based
applications.
Expand Down
9 changes: 0 additions & 9 deletions activator.properties

This file was deleted.

77 changes: 77 additions & 0 deletions backend/src/main/resources/application.conf
@@ -0,0 +1,77 @@
api {
host = "localhost"
host = ${?API_HOST}

port = 8080
port = ${?API_PORT}
}

db {
username = "postgres"
username = ${?SQL_USERNAME}

password = ""
password = ${?SQL_PASSWORD}

name = "bootzooka"
name = ${?SQL_DBNAME}
host = "localhost"
host = ${?SQL_HOST}
port = 25432
port = ${?SQL_PORT}

url = "jdbc:postgresql://"${db.host}":"${db.port}"/"${db.name}

migrate-on-start = true
migrate-on-start = ${?MIGRATE_ON_START}

driver = "org.postgresql.Driver"

connect-thread-pool-size = 32
}

email {
enabled = false
enabled = ${?EMAIL_ENABLED}

smtp {
host = ""
host = ${?EMAIL_HOST}

port = 25
port = ${?EMAIL_PORT}

username = ""
username = ${?EMAIL_USERNAME}

password = ""
password = ${?EMAIL_PASSWORD}

ssl-connection = false
ssl-connection = ${?EMAIL_SSL_CONNECTION}

verify-ssl-certificate = true
verify-ssl-certificate = ${?EMAIL_VERIFY_SSL_CERTIFICATE}
}

encoding = "UTF-8"
encoding = ${?EMAIL_ENCODING}

from = "info@bootzooka.com"
from = ${?EMAIL_FROM}

batch-size = 10
batch-size = ${?EMAIL_BATCH_SIZE}

email-send-interval = 1 second
email-send-interval = ${?EMAIL_SEND_INTERVAL}
}

password-reset {
reset-link-pattern = "http://localhost:8080/#/password-reset?code=%s"
code-valid-hours = 24
}

bootzooka {
default-api-key-valid-hours = 24
}
72 changes: 44 additions & 28 deletions backend/src/main/resources/db/migration/V1__create_schema.sql
@@ -1,35 +1,51 @@
-- USERS
CREATE TABLE "users"(
"id" UUID NOT NULL,
"login" VARCHAR NOT NULL,
"login_lowercase" VARCHAR NOT NULL,
"email" VARCHAR NOT NULL NOT NULL,
"password" VARCHAR NOT NULL NOT NULL,
"salt" VARCHAR NOT NULL NOT NULL,
"created_on" TIMESTAMP NOT NULL
CREATE TABLE "users"
(
"id" TEXT NOT NULL,
"login" TEXT NOT NULL,
"login_lowercase" TEXT NOT NULL,
"email_lowercase" TEXT NOT NULL,
"password" TEXT NOT NULL,
"created_on" TIMESTAMPTZ NOT NULL
);
ALTER TABLE "users" ADD CONSTRAINT "users_id" PRIMARY KEY("id");
ALTER TABLE "users"
ADD CONSTRAINT "users_id" PRIMARY KEY ("id");
CREATE UNIQUE INDEX "users_login_lowercase" ON "users" ("login_lowercase");
CREATE UNIQUE INDEX "users_email_lowercase" ON "users" ("email_lowercase");

-- API KEYS
CREATE TABLE "api_keys"
(
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"created_on" TIMESTAMPTZ NOT NULL,
"valid_until" TIMESTAMPTZ NOT NULL
);
ALTER TABLE "api_keys"
ADD CONSTRAINT "api_keys_id" PRIMARY KEY ("id");
ALTER TABLE "api_keys"
ADD CONSTRAINT "api_keys_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- PASSWORD RESET CODES
CREATE TABLE "password_reset_codes"(
"id" UUID NOT NULL,
"code" VARCHAR NOT NULL,
"user_id" UUID NOT NULL,
"valid_to" TIMESTAMP NOT NULL
CREATE TABLE "password_reset_codes"
(
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"valid_until" TIMESTAMPTZ NOT NULL
);
ALTER TABLE "password_reset_codes" ADD CONSTRAINT "password_reset_codes_id" PRIMARY KEY("id");
ALTER TABLE "password_reset_codes" ADD CONSTRAINT "password_reset_codes_user_fk"
FOREIGN KEY("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "password_reset_codes"
ADD CONSTRAINT "password_reset_codes_id" PRIMARY KEY ("id");
ALTER TABLE "password_reset_codes"
ADD CONSTRAINT "password_reset_codes_user_fk"
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- REMEMBER ME TOKENS
CREATE TABLE "remember_me_tokens"(
"id" UUID NOT NULL,
"selector" VARCHAR NOT NULL,
"token_hash" VARCHAR NOT NULL,
"user_id" UUID NOT NULL,
"valid_to" TIMESTAMP NOT NULL
-- EMAILS
CREATE TABLE "scheduled_emails"
(
"id" TEXT NOT NULL,
"recipient" TEXT NOT NULL,
"subject" TEXT NOT NULL,
"content" TEXT NOT NULL
);
ALTER TABLE "remember_me_tokens" ADD CONSTRAINT "remember_me_tokens_id" PRIMARY KEY("id");
ALTER TABLE "remember_me_tokens" ADD CONSTRAINT "remember_me_tokens_user_fk"
FOREIGN KEY("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
CREATE UNIQUE INDEX "remember_me_tokens_selector" ON "remember_me_tokens"("selector");
ALTER TABLE "scheduled_emails"
ADD CONSTRAINT "scheduled_emails_id" PRIMARY KEY ("id");
2 changes: 0 additions & 2 deletions backend/src/main/resources/db/migration/V2__add_indexes.sql

This file was deleted.

18 changes: 5 additions & 13 deletions backend/src/main/resources/logback.xml
Expand Up @@ -3,25 +3,17 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n%rEx</pattern>
<pattern>%d{HH:mm:ss.SSS}%boldYellow(%replace( [%X{cid}] ){' \[\] ', ' '})[%thread] %-5level %logger{5} - %msg%n%rEx</pattern>
</encoder>
</appender>

<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
</appender>

<logger name="com.softwaremill.bootzooka" level="DEBUG" additivity="false">
<appender-ref ref="ASYNC" />
<logger name="com.softwaremill.bootzooka" level="${LOG_LEVEL:-DEBUG}" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<!-- Strictly speaking, the level attribute is not necessary since -->
<!-- the level of the root level is set to DEBUG by default. -->
<root level="INFO">
<appender-ref ref="ASYNC" />
<root level="${LOG_LEVEL:-INFO}">
<appender-ref ref="STDOUT"/>
</root>

</configuration>
103 changes: 0 additions & 103 deletions backend/src/main/resources/reference.conf

This file was deleted.

Expand Up @@ -2,4 +2,4 @@
--
Regards,
SoftwareMill Bootzooka Dev Team
http://SoftwareMill.com
http://softwaremill.com
3 changes: 1 addition & 2 deletions backend/src/main/resources/templates/email/resetPassword.txt
@@ -1,7 +1,6 @@
SoftwareMill Bootzooka password reset

Dear {{userName}},

To be able to set a new password, please visit the link below:

{{resetLink}}
{{resetLink}}

0 comments on commit cad2707

Please sign in to comment.