Skip to content

Getting Started

Mees van Straten edited this page Dec 9, 2021 · 18 revisions

About

This wiki article explains the steps and tools that are necessary in order to get the backend services running.

The backend consist of the services:

  • API (https://localhost:5001)
  • Identity Server (https://localhost:5005)
  • Database
  • Notification system
    The notification system is responsible for sending emails ( in the future this may be expanded with sending notifications to the frontend )
  • Job Scheduler
    The Job Scheduler is responsible for starting jobs every now and then. For now it is only used to check for graduating users.
  • Elastic Synchronizer
    Elastic Synchronizer is an application which is responsible sending calls to the ElasticSearch instance to keep our MSSQL database up to date with the Elastic dataset.

Setup with docker

Prerequisites

Steps

  1. Clone this repository, using the following command:
    git clone https://github.com/DigitalExcellence/dex-backend.git
  2. Browse to the folder of the repository
  3. Run the command: docker-compose up (If you want to run it in the background: docker-compose up -d) (if you need to rebuild the images use: docker-compose up --build)
  4. After a short while, the services should be running and accessible on the urls mentioned in the about section
  5. When you visit the urls for the first time, you should trust the certificate
  6. When you want to stop the services from running, run the command: docker-compose down

Setup with Visual Studio

Prerequisites

  • Git
  • Visual Studio
  • RabbitMQ RabbitMQ can be installed as a service from the link on the left, but you can also use the RabbitMQ container in our Docker Compose file. It could be necessary to enable the management plugin for RabbitMQ by using the following command for RabbitMQ either in the Docker container or locally. rabbitmq-plugins enable rabbitmq_management See RabbitMQ documentation for more information.
  • App__SendGrid__EmailFrom envoirement variable.
  • App__SendGrid__ApiKey envoirement variable.

These two envoirement variables are available from the password manager, ask the project lead.

Steps

  1. Clone backend repository
  2. Open solution
  3. Right click -> Set as startup projects: Choose "Multiple startup projects" and select action 'Start' for 1_API and 8_IdentityServer

If the error below shows up your instance of RabbitMQ may not be running or the connection credentials ( appsettings.Development.json ) may be incorrect.
image

Tips

After launch: check if database is created by using SQL Server Object Explorer. To check if API is working:

  1. Use https://localhost:5001/index.html and click on Authorize.
  2. Select Scopes: 'dex-api'
  3. Use user: 'bob' password: 'bob' to authorize.
  4. Click one of the API requests and check for response.

Setup with Rider

Prerequisites

  • Git
  • Rider
  • RabbitMQ RabbitMQ can be installed as a service from the link on the left, but you can also use the RabbitMQ container in our Docker Compose file.

Steps

  1. Clone backend repository.
  2. Open solution.
  3. Ga naar Run -> Edit Configurations.
  4. Press the + sign and add two .NET Projects, one for the API and one for the Identity server.
  5. Press the + sign and add a Compound.
  6. Press the made Compound and the the API and the Identity server.

Here is a video that shows these steps.

XUnit setup

Prerequisites

Steps

When running XUnit in the docker container the following steps apply:

  1. run docker-compose up (for the backend)
  2. run docker build -t dex-backend_xunit -f API.Tests/Dockerfile . from the root of the repository. When new tests are added this builds the new image.
  3. run docker run -e "ApiAddress=https://api:5001/" -e "IdentityAddress=http://identity:5004/" --network dex-backend_mssql-network dex-backend_xunit Create a container with the newly build image. All XUnit tests will be executed automatically.

When you want to run the XUnit tests in your IDE you will need the two enviroment variables listed above. After that you can run the tests via the Test explorer like a normal .NET test.

Postman setup

Prerequisites

Steps

  1. Import both environment & collection .json files from backend repository in Postman.
  2. Make sure 'SSL certificate verification' setting in Postman is disabled.
  3. Collection: 'Digital-Excellence-API' should be under collections in the left panel. Environment 'Local' should be available in the top right corner of Postman.

More instruction about Postman can be found here: Postman guide