Initialise a Scala Play project with a MongoDB controller for Feed Service
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).