Skip to content

uk-gov-mirror/DFE-Digital.manage-courses-api

 
 

Repository files navigation

Manage Courses API project

Build Status

About

This repo provides a dotnet core solution containing:

  • An API for managing courses data.
  • A Domain to describe the managing course data.
  • Regression tests.

The main clients for this API and library are

Coding

It can be worked on in either VSCode or Visual Studio 2017 as preferred.

The project follows https://semver.org/ version numbering.

Configuration

For additional details, refer to https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-2.1&tabs=windows

https://dfedigital.atlassian.net/wiki/spaces/BaT/pages/389349377/Manage+Courses+API

Getting started from scratch

Database setup

Mac/linux

./setup-pg-user.sh

Setup Email functionality

cd src/ManageCourses.Api/
dotnet user-secrets set email:user the-user-email-address

Values available from GOV.​UK Notify

cd src/ManageCourses.Api/
dotnet user-secrets set email:template_id the-template-id
dotnet user-secrets set email:api_key the-email-api-key
dotnet user-secrets set email:welcome_template_id the-welcome-template-id

Setup Authentication

UI related

# from .\src\ManageCourses.Api>
dotnet user-secrets set auth:oidc:userinfo_endpoint the-oidc-userinfo-endpoint
# from .\src\ManageCourses.Api>
dotnet user-secrets set snc:api:key the-search-and-compare-api-key
dotnet user-secrets set snc:api:url the-search-and-compare-api-url

Running the API locally

cd src/ManageCourses.Api/
dotnet run

Logging

Logging is configured in appsettings.json, and values in there can be overridden with environment variables.

Powershell:

$env:Serilog:MinimumLevel="Debug"
dotnet run

Command prompt

set Serilog:MinimumLevel=Debug
dotnet run

For more information see:

Serilog has been configured to spit logs out to both the console (for dotnet run testing & development locally) and Application Insights.

Set the APPINSIGHTS_INSTRUMENTATIONKEY environment variable to tell Serilog the application insights key.

Error tracking

This app sends exceptions and errors into Sentry. To enable the integration, set the SENTRY_DSN environment variable.

Running tests

cd tests\ManageCourses.Tests\
dotnet test

Smoke tests

These need internet access and the following additional user secrets

  • credentials:dfesignin:clientsecret
  • credentials:dfesignin:username (User name of an existing account on the Dfe Sign in test server)
  • credentials:dfesignin:password (...and corresponding password)

Using the API

The API exposes swagger at /swagger thanks to NSwag

You can use the generators to generate client code from the API. See: https://github.com/RSuter/NSwag/wiki#ways-to-use-the-toolchain

Database Migrations

These are now managed by the sister project https://github.com/DFE-Digital/manage-courses-backend/

Shutting down the service and showing the off line page.

Rename the file "app_offline.htm.example" in the root folder to "app_offline.htm"

About

ye olde c# codebase for publish, dead

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.8%
  • Other 1.2%