Micro service - handshake [Deprecated]

All micro services will communicate with the Core service via a secure token protocol. Once installed, the core will generate a unique key (called shared secret from now on) which will be used by all micro services' first communication (called first handshake from now on). On first handshake, the core will generate a unique key for each micro service which will be used from then on to access the core's features. Also, during this process, the micro service will send the core all it's frontend JS modules urls along with it's base url.

Doing the first handshake - backend

The core will expose a public endpoint called registerMicroservice which will be used to register a new micro service with the core. 

The newly registered micro service will not be active at first, needing to be activated from the core dashboard and added to existing roles!

Request

Endpoint URL: /api/registerMicroservice
Method: POST
Headers
ParameterDescription
X-Api-KeyShared secret generated by Core, provided by the core administrator (should be visible via the core dashboard)
X-Requested-With

Value should always be XMLHttpRequest

(depending on the technology used, this header could already be present in the request)

Body
ParameterRequiredDescription
nameYes

Module friendly name

(no limitations, can be changed in time

example: OMS Events module)

codeyes

Module internal name

(no spaces, all lowercase, cannot be changed once registered,

example: oms_events)

base_urlyes

Module base url

(URL where the module is accessible, the frontend root,

example: https://moduleName.domain.tld)

pagesyes

JSON array containing frontend pages data

Each entity inside the array should contain the following attributes:

name - Frontend friendly name (example: List events)

code - Frontend internal name (example: list_events) - This one should be the same with the AngularJS module name defined in the module

module_link - relative path to base_url to the module JS file (example: frontend/list_events.js)

Example of pages object
[
	{
		"name": "Test page1",
		"code": "test_page1",
		"module_link": "frontend/testpage1.js",
		"icon": "fa fa-cog"
	}, {
		"name": "Test page2",
		"code": "test_page2",
		"module_link": "frontend/testpage2.js",
		"icon": "fa fa-cog"
	}
]

Response

Response

Description

{
    "success": 1,
    "handshake_token": "$2y$10$Eoe7cShmtqELNy918Qyf0.qomLr5DKvAJfudFQtJEnKLbk.zeI8jS"
}



Returns success flag and the handshake token which will be used for further calls to the core

{
    "success": 0,
    "message": "Field name is required!"
}
Error call

HTTP Code 403

Unauthorized call.

Shared secret invalid


Doing the first handshake - frontend

Each micro service is responsible for managing it's own frontend!

All micro services will be accessed using their own frontend pages registered via the first handshake. The frontend needs to be developed using Angular JS and Angular UI Router.

Anything that has a standalone Angular JS module needs to be registered, even if it is nested.

Example of frontend JS module
(function ()
{
    'use strict';
    var baseUrl = baseUrlRepository['module_poc'];


    angular
        .module('app.hello_world', [])
        .config(config)
        .controller('HWController', HWController);

    /** @ngInject */
    function config($stateProvider)
    {
        // State
         $stateProvider
            .state('app.hello_world', {
                url: '/hello_world',
                data: {'pageTitle': 'Hello world'},
                views   : {
                    'pageContent@app': {
                        templateUrl: baseUrl+'frontend/hello_world/hello_world.html',
                        controller: 'HWController as vm'
                    }
                }
            });
    }

    function HWController($http) {
        // Data

        var vm = this;
        
        // Methods

        /////
    }

})();