This is the reviews service for the bulletin board application. Reviews refer to the users who advertise things, not the advertised things. The server is written in Node.js. The client is written using Preact and SAP UI5 Web Components. The purpose of this application is to demonstrate Microservice development and related tradeoffs. In particular, the service bulletinboard-ads is tightly coupled to this service, through a synchronous HTTP call to an API for a very specific feature that the advertisements service needs. This is a typical pitfall in Microservice development and can be mitigated by leveraging eventual consistency & asynchronous communication.
The following tools are required to run the service locally:
- Node.js, v16 or later
- Docker engine, v20 or later
- Alternatively, a PostgreSQL database, v9.6 or later
- Optionally a Bourne shell
- Provided shell scripts make the startup easier
- Git bash is a good choice for Windows users
- Start a pre-configured database using Docker:
./start-db.sh
- If you want to start the database manually, or use your own PostgreSQL installation without Docker, have a look into the shell script to know the required configuration for version, database name, port, credentials and schema
- Install the required dependencies:
npm ci
- Run the tests:
npm test
- Start the service:
npm start
- The service will listen on port 9090
For a deployment on Cloud Foundry, a pre-configured manifest.yaml with placeholders is provided.
For a deployment on Kubernetes, a pre-configured k8s-minimal.yaml with placeholders is provided, along with a basic Dockerfile.
The following endpoints are supported and tested:
GET /api/v1/averageRatings/:contact
: get the average rating of a given contact- Response:
200 OK
- Response Body:
{ "average_rating": <number> }
- Response:
GET /api/v1/reviews
: get all reviews- Response:
200 OK
- Response Body:
[ { "reviewee_email": <text>, "reviewer_email": <text>, "rating": <integer>, "comment": <text> }, ... ]
- Response:
POST /api/v1/reviews
: post a new review- Request Headers:
Content-Type: application/json
- Request Body:
{ "reviewee_email": <text>, "reviewer_email": <text>, "rating": <integer>, "comment": <text> }
- Response:
204 No Content
- Request Headers:
DELETE /api/v1/reviews
: delete all reviews- Response:
204 No Content
- Response:
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.