-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mikolajkapica/feature/4
Feature/4
- Loading branch information
Showing
8 changed files
with
102 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
alerts: | ||
- rule: DEPLOYMENT_FAILED | ||
- rule: DOMAIN_FAILED | ||
databases: | ||
- cluster_name: elevator-system-db | ||
engine: MONGODB | ||
name: elevator-system-db | ||
production: true | ||
version: "7" | ||
features: | ||
- buildpack-stack=ubuntu-22 | ||
ingress: | ||
rules: | ||
- component: | ||
name: elevator-system-api | ||
match: | ||
path: | ||
prefix: /api | ||
name: dolphin-app | ||
region: fra | ||
services: | ||
- dockerfile_path: /api/Dockerfile | ||
envs: | ||
- key: DATABASE_URL | ||
scope: RUN_TIME | ||
value: ${elevator-system-db.DATABASE_URL} | ||
- key: CA_CERT | ||
scope: RUN_TIME | ||
value: ${elevator-system-db.CA_CERT} | ||
github: | ||
branch: feature/4 | ||
deploy_on_push: true | ||
repo: mikolajkapica/elevator-system | ||
http_port: 8080 | ||
instance_count: 2 | ||
instance_size_slug: apps-s-1vcpu-1gb | ||
name: elevator-system-api | ||
source_dir: api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,9 @@ | ||
import org.mongodb.scala.Document | ||
import org.mongodb.scala.MongoClient | ||
import org.mongodb.scala.MongoCollection | ||
|
||
import tour.Helpers._ | ||
import org.mongodb.scala.MongoDatabase | ||
|
||
object Database { | ||
|
||
def test(): Unit = | ||
println("Connecting to MongoDB...") | ||
val mongoClient = MongoClient(sys.env("DATABASE_URL")) | ||
val database = mongoClient.getDatabase("mydb") | ||
database.createCollection("test2") | ||
val collection: MongoCollection[Document] = database.getCollection("test2") | ||
|
||
val document = Document( | ||
"name" -> "MongoDB", | ||
"type" -> "database", | ||
"count" -> 1, | ||
"info" -> Document("x" -> 203, "y" -> 102), | ||
) | ||
|
||
collection.insertOne(document).results() | ||
collection.find().printResults() | ||
println("Document inserted") | ||
def connect(db_name: String): MongoDatabase = MongoClient(sys.env("DATABASE_URL")) | ||
.getDatabase(db_name) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Database.connect | ||
import akka.http.scaladsl.model.ContentTypes | ||
import akka.http.scaladsl.model.HttpEntity | ||
import akka.http.scaladsl.server.Directives.complete | ||
import akka.http.scaladsl.server.Directives.get | ||
import akka.http.scaladsl.server.Directives.path | ||
import akka.http.scaladsl.server.Directives.pathSingleSlash | ||
import akka.http.scaladsl.server.Route | ||
import akka.http.scaladsl.server.Directives._enhanceRouteWithConcatenation | ||
import org.mongodb.scala.bson.collection.immutable.Document | ||
import tour.Helpers._ | ||
|
||
object Router { | ||
|
||
val route: Route = | ||
pathSingleSlash { | ||
get { | ||
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Welcome to the API</h1>")) | ||
} | ||
} ~ | ||
path("hello") { | ||
get { | ||
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>")) | ||
} | ||
} ~ | ||
path("health") { | ||
get { | ||
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>OK</h1>")) | ||
} | ||
} ~ | ||
path("db-test") { | ||
get { | ||
val db = connect("test") | ||
db.createCollection("test") | ||
db.getCollection("test").insertOne(Document("name" -> "test")).results() | ||
val result = db.getCollection("test").find().results().map(_.toJson).mkString(", ") | ||
|
||
complete( | ||
HttpEntity( | ||
ContentTypes.`text/html(UTF-8)`, | ||
s"<h1>DB Test</h1><p>Result: $result</p>", | ||
) | ||
) | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters