1.0.1 • Published 5 months ago

galleri-mesh-client v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Repository Template

CI/CD Pull Request Quality Gate Status

Welcome to the Galleri MESH client. This repository houses a Javascript MESH client which is used by the Galleri project to communicate with MESH, however it is intended to be universal so any teams that want to use javascript to talk to mesh could utilize this client

Table of Contents

Setup

This client is compatible with the sandbox, integration and production MESH systems. To use it follow these instructions:

  1. Clone the repository
git clone https://github.com/nhs-england-tools/repository-template.git
  1. If you are using the sandbox then turn it on and run npm test to check everything is working If you are using the integration environment then you will need to set up the following variables to override the defaults for the sandbox environment. You can do this by either updating your ~/.bashrc for linux or ~/.zshrc or you can put the values into a .env file in the repo, it will be excluded by .gitignore
# Required variables

# enables or disabled sandbox mode, this should be set to `true` for the sandbox or `false` for integration environments
export MESH_SANDBOX=true

# The ID of the mailbox that you want to send messages from, default is the mesh-sandbox id
export MESH_SENDER_MAILBOX_ID="X26ABC1"

# The Password of the mailbox that you want to send messages to, default is the mesh-sandbox password
export MESH_SENDER_MAILBOX_PASSWORD="password"

# The ID of the mailbox that you want to receive messages from, default is the mesh-sandbox id
export MESH_RECEIVER_MAILBOX_ID="X26ABC2"

# The Password of the mailbox that you want to receive messages to, default is the mesh-sandbox password
export MESH_RECEIVER_MAILBOX_PASSWORD="password"

# The location of the certificate used by the sending mailbox, only required for integration and production.
MESH_SENDER_CERT_LOCATION="/cert/location/here"

# The location of the key used with the certificate above, only required for integration and production.
MESH_SENDER_KEY_LOCATION="/cert/location/here"

# The location of the certificate used by the receiving mailbox, only required for integration and production.
MESH_RECEIVER_CERT_LOCATION="/cert/location/here"

# The location of the key used with the certificate above, only required for integration and production.
MESH_RECEIVER_KEY_LOCATION="/cert/location/here"

# The location of the CA cert which is required for integration and production MESH systems.
MESH_SENDER_CA_LOCATION="/cert/location/here"

# Set the log level you want to see, for testing the recommended setting is `DEBUG` but there are also `ERROR` and `INFO` levels
LOG_LEVEL="DEBUG"

# The message content that will be delivered
MESH_MESSAGE="This is a test"
  1. cd into the repository
cd galleri-mesh-client
  1. run the integrated test by running npm test to verify that everything is working.

Prerequisites

The following software packages, or their equivalents, are expected to be installed and configured:

  • docker container runtime or a compatible tool, e.g. podman,
  • asdf version manager,
  • GNU make 3.82 or later,
  • GNU coreutils and GNU binutils may be required to build dependencies like Python, which may need to be compiled during installation. For macOS users, this has been scripted and automated by the dotfiles project; please see this script for details,
  • Python required to run Git hooks,
  • jq a lightweight and flexible command-line JSON processor.

!NOTE The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain make tasks will fail. On macOS, you will need homebrew installed, then to install make, like so:

brew install make

You will then see instructions to fix your $PATH variable to make the newly installed version available. If you are using dotfiles, this is all done for you.

Configuration

Installation and configuration of the toolchain dependencies

make config

Usage

See MeshService.test.js to see an implementation of the mesh module services configured to send and receive a message/file.

You will need the dotenv package for the following. To connect to the sanbox environment the following environmental variables need to be set:

LOG_LEVEL="DEBUG"
MESH_URL="https://localhost:8700"
MESH_SHARED_KEY="TestKey"
MESH_SENDER_MAILBOX_ID="X26ABC1"
MESH_SENDER_MAILBOX_ACCESS_ID=""
MESH_RECEIVER_MAILBOX_ID="X26ABC2"
MESH_RECEIVER_MAILBOX_ACCESS_ID=""
MESH_DATA_FILE="./tests/testdata-organizations-100000.csv"
MESH_SANDBOX="true"
MESH_RECEIVE_TIMEOUT="30"

Alternatively see meshModuleTemplate.js which contains an example on connecting to your own MESH Mailbox by setting your own environmental variables.

MESH module services

The module contains a Loader, SenderService, ReceiverService and MeshService classes that need to be configured.

Once dotenv is installed, set your values in your .env file including the message and/or file to transmit. The Loader class will initialise the environmental variables. User loaderInstance.state() to debug the values.

The SenderService instance takes loaderInstance.senderConfig() as an argument and sets the senderInstance values. You can pass in different loaderInstances to configure multiple senderInstances. A Payload object containing the message and/or file to transmit. A destination which is the receiver mailbox id.

The receiverService instance takes loaderInstance.receiverConfig() as an argument and sets the receiverInstance values. You can pass in different loaderInstances to configure multiple receiverInstances.

The MeshServices instance takes as argument a senderInstance and a receiverInstance and creates a sender/receiver relationship between the two instances. You can use meshInstance to call sendMessage(), sendFile() and receiveMessage(). You can configure multiple meshInstances with different sender/receiver instances and allow relationships between different senders and receivers.

Testing

There are make tasks for you to configure to run your tests. Run make test to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.

npm test will execute meshService.test.js.

Design

Diagrams

The C4 model is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points.

Repository Template

Modularity

Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data.

Contributing

Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like

  • Environment setup for contribution, i.e. CONTRIBUTING.md
  • Coding standards, branching, linting, practices for development and testing
  • Release process, versioning, changelog
  • Backlog, board, roadmap, ways of working
  • High-level requirements, guiding principles, decision records, etc.

Contacts

Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc.

Licence

The LICENCE.md file will need to be updated with the correct year and owner

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.

Any HTML or Markdown documentation is © Crown Copyright and available under the terms of the Open Government Licence v3.0.

1.0.1

5 months ago

1.0.0

5 months ago