Initialise a Scala Play project with a MongoDB controller for Feed Service
4 unresolved threads
4 unresolved threads
What does this MR do?
- Initialises a Scala Play project for the Feed Service
- Adds a MongoDB Controller that abstracts useful MongoDB functions from the Scala Driver for testing.
- Adds dockerisation for the service.
Testing (w/out Docker)
Scala-Play Requirements
To run a Scala Play project locally on Unix system, use the following instruction:
-
Download SDKMAN using curl -s "https://get.sdkman.io" | bash
-
From the available JDK distributions, download the Amazon Corretto OpenJDK v11.0.18 using sdk install java 11.0.18-amzn
-
Ensure it is installed by running java -version
, you should see the following:
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.18.10.1 (build 11.0.18+10-LTS, mixed mode)
-
Install sbt with SDKMAN: sdk install sbt
You should now be ready to run a Scala Play application.
MongoDB Perquisites
-
Ensure a local MongoDB service is running on your computer (Guide). -
(Optional) Install MongoDB Compass for a simple MongoDB UI. -
Create a database. -
Create a collection. -
Add a few records to the collection.
MongoDB Endpoint Test
-
In backend-services/feed-service/MongoTestController
, update lines 25-26 with your chosen database/collection names. -
In a terminal, navigate to backend-services/feed-service/
-
Run sbt run
. -
Navigate to http://localhost:9000/mongo_test. -
A list of the records in collection appear on site.
Testing (with Docker)
-
Ensure Docker is installed and running. -
Run the following command in the root directory: docker-compose up --build
-
Create a database. -
Create a collection. -
Add a few records to the collection. -
After services load and creating records, navigate to http://localhost:9001/mongo_test. -
A list of the records in collection appear on site.
Relevant issues
Closes #17 (closed). Closes #18 (closed).
Merge request reports
Activity
added back-end feed-service labels
requested review from @mk01311
assigned to @fd00246
added 1 commit
- 3be4b264 - Move MongoDB Connection string to config file (#18 (closed))
1 @($model;format="camel"$Form: Form[$model;format="Camel"$Data])(implicit request: MessagesRequestHeader) 2 3 <h1>$model;format="camel"$ form</h1> 4 5 @request.flash.get("success").getOrElse("") 6 7 @helper.form(action = routes.$model;format="Camel"$Controller.$model;format="camel"$Post()) { 8 @helper.CSRF.formField 9 @helper.inputText($model;format="camel"$Form("name")) 10 @helper.inputText($model;format="camel"$Form("age")) 11 <input type="submit" value="submit"/> 12 } 1 @() 2 3 @main("Welcome to Play") { 4 <h1>Welcome to Play!</h1> 5 } changed this line in version 5 of the diff
10 <html lang="en"> 11 <head> 12 @* Here's where we render the page title `String`. *@ 13 <title>@title</title> 14 <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")"> 15 <link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")"> 16 17 </head> 18 <body> 19 @* And here's where we render the `Html` object containing 20 * the page content. *@ 21 @content 22 23 <script src="@routes.Assets.versioned("javascripts/main.js")" type="text/javascript"></script> 24 </body> 25 </html> changed this line in version 5 of the diff
added 2 commits
mentioned in commit 1ae36797
Please register or sign in to reply