You have a database ready in a docker image, with necessary schema and a script to seed the data. Your goal is to implement a HTTP server with a single EP to return JSON data for the feature described bellow.
Start the database
$ cd docker-compose
$ docker-compose up
This will create and start the database and prepare the schema.
You can read the connection details in ./docker-compose/docker-compose.yml
.
$ npm ci
$ npm run seed-data
STARTING..................................................DONE
Inspect the database now, we have users
, that created some recipes
. Users can also rate the recipes
using reviews
and each review has a rating.
Implement a HTTP server that returns newest popular recipes.
http://localhost:3000/api/popular-recipes
must return a valid JSON response with array of recipes, see example response- Select only receipts with an average rating higher than
8
- Order results by
publish_time
. If it is null, usecreate_time
instead, newest first - Return first 20 items only
Example response:
[{
"id": "42",
"name": "The Tasty Yellowstripe scad with lavender eyeballs",
"mainIngredient": "fish",
"publishTime": "2022-04-13T12:40:27.682Z",
"averageRating": 8.5
}]
We found out that reviews from people who have at least once reviewed a meal with main ingredient fish are more relevant. Exclude from calculation reviews from users that have not reviewed fish at least once.
- Task is very minimal due to limited time. Try to put as much effort as you worked on production code the way you are used to (clean Git history, tests and any tools and processes etc.)
- If you get stuck for 15-20 minutes, feel free to reach and consult your buddy
- The libraries used are completely up to you. If you are in doubt discuss with your buddy. But do use Node.js
- Don't mind the code and dependencies used in existing files