Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Koa - Koa is a new web application framework for node.js. It provides easy mechanisms to expose web endpoints and process requests and responses in a stack-like approach.Connect - Connect provides middleware for node.js that allow HTTP requests and responses can be altered while in 'flight'. The express framework also uses connect middleware and middleware are exposed from the express framework as well.
  • Passport.js - Middleware to provide authentication mechanisms.

General Overview

The Koa framework provides an easy way to modify HTTP request and responses as they are being processed. Each step that the OpenHIM needs to perform can be written as Koa middleware. Each middleware can handle a different aspect of processing that the OpenHIM need to perform such as authentication, authorization, message persistence and message routing. Developing each of these steps as Koa middleware allows them to be easily reused and allows us to add new steps for future versions. Koa stack approach to processing requests also fit our usecase well as it allows the middleware to affect both the request and the response as it is travelling through the system.

...

In addition the ability to store orchestration steps exists in the structure. We anticipate exposing a web service to enable mediators to report requests and responses that they make to/receive from external services and have these stored alongside the actual transaction.We will use the plain mogodb node library rather than using an ORM such as Mongoose. Mongoose helps with schema validation, casting and write object business logic. We don't require these features as the documents that we are storing are relatively simple. Also, Mongoose want you to define data types for everything in the schema. It does not easily allow you to add dynamic elements to your documents. Thus, following the KISS principle we will not make use of any ORM until the need and reason for its use is evident.

Code Block
titletransaction.json
{
	"_id": "123",
	"status": "Processing|Failed|Completed",
	"applicationId": "Musha_OpenMRS",
	"request": {
		"path": "/api/test",
		"headers": [
			{ "header1": "value1" },
			{ "header2": "value2" }
		],
		"requestParams": [
			{ "param1": "value1" },
			{ "param2": "value2" }
		],
		"body": "<HTTP body>",
		"method": "POST",
		"timestamp": "<ISO 8601>"
	},
	"response": {
		"status": 201,
		"body": "<HTTP body>",
		"headers": [
			{ "header1": "value1" },
			{ "header2": "value2" }
		],
		"timestamp": "<ISO 8601>"
	},
	"routes": [
		{
			"name": "<route name>"
			// Same structure as above
			"request": { ... },
			"response": { ... }
		}
	]
	"orchestrations": [
		{
			"name": "<orchestration name>"
			// Same structure as above
			"request": { ... },
			"response": { ... }
		}
	]
	"properties": [ // optional meta data about a transaction
		{ "prop1": "value1" },
		{ "prop2": "value2" }
	]
}

...