Midgard

Summary

Midgard is the frontend of your microservice architecture. It builds a web application in the JavaScript framework of your choice that communicates with the API exposed by BiFrost and implements the logic modules that you added to your application.

Midgard adds a set of core features to the web application, such as user management. Any clients that you added to your application will provide extra views and/or UI components.

Customize the frontend

Walhall forks an application root repository to your GitHub account when you create an application. This repository contains the source code of your web application, built by Midgard in the frontend framework you selected during the creation process. It will have the same name as your application.

The README will contain instructions on how to set up and develop the application locally. You can preview the README here:

Midgard-core features

The core features of Midgard are included in your application as a package called midgard-core. Check the README in your application root for information on how they are implemented in each JS framework.

HTTP client

Midgard uses the HTTP client to communicate with the application’s backend services. It exposes one method for making HTTP requests of all kinds: request. The request method wraps the axios library.

Redux store

Midgard includes a plain Redux store (implemented by the Redux npm package) with redux-observable on top to provide support using observables.

The following functions from redux and redux-observable are included:

  • createStore
  • createSelector
  • combineReducers
  • combineEpics
  • ofType
  • createEpicMiddleware
  • applyMiddleware
  • compose

OAuth client

The simple OAuth client handles user authentication with the application using BiFrost’s core user data model. Currently it only supports credential-based authentication provided through the authenticateWithCredentials method.

Logging library

The logging library exposes a Logger class, which can be instantiated with a few configuration properties:

  • logToConsole: Specifies whether or not logged messages should be logged to the console as well
  • logToServer: Specifies whether or not logged messages should be logged to the server as well
  • APIURL: Server endpoint where logged messages will be sent. If this is not defined, then the logged messages will go to the endpoint defined in the environment variables for the deployment.

Logged messages can be categorized according to various levels. Currently, those levels are:

  • LOG
  • TRACE
  • DEBUG
  • WARN
  • ERROR

The logger will attempt to route messages to the correct console method, if it is available, based on the logLevel defined. Server-side logging will also separate log messages based on these categories.

Midgard-schematics

Midgard-schematics is a Gulp task that initializes the application and puts together the UI based on the source code provided by Midgard and the logic modules.

See the Midgard-schematics page for more information.