A demo service to show how to develop a Platform 6 service with C# using Platform 6 C# connector.
- Launch a local instance of Platform 6.
- Read and fulfill the requirements of Platform 6 C# connector.
This project shows how to:
- create a simple Nancy application server,
- initialize a custom service on Platform 6,
- implement the endpoint that displays the service's user interface
Every service should have a configuration interface. It is the main screen displayed when a user clicks on the associated entry menu in the Platform 6 Portal. Here's the configuration interface of our demo service:
This interface is defined in the file ServiceConfiguration.tsx
which has been developed using the framework React.
For now React is the only supported library on Platform 6.
The user interface must export a single main React component through a bundled JavaScript file (see Webpack for bundling and Babel for transpiling). This script will be injected and displayed on the Portal.
To help you build the user interface of your custom service, a set of components is ready for use on Platform 6.
They can be included as a JavaScript dependency from the library platform6-ui-components
.
The documentation of these components is available online.
Go in the client's directory and install its dependencies:
$ cd Platform6/Client
$ npm install
Compile the TypeScript source files to generate the compiled bundle file Platform6/Client/build/ServiceConfiguration.bundle.js
:
$ npm run build
You can also use the watch mode to generate a new bundle file after every change made to the source files. The command is then:
npm run build:watch
.
The server in the demo is built using the framework Nancy. To launch it, from the root directory:
Install the dependencies:
$ cd Platform6
$ mkdir packages && cd packages
$ nuget install ../packages.config
Build the server:
Compile the C# classes to create the .exe
in the folder bin/Debug/
.
$ msbuild Platform6/Service.csproj
Run the server:
From the directory bin/Debug/
, export some environment variables:
$ export B2BOX_HOST=localhost && export EXTERNAL_URL=http://localhost:8888
Use Mono to run the project:
$ mono ./Service.exe
It should launch a server on the port 8888
then deploy the service demo.csharp on Platform 6.
An entry menu Csharp should appear in the menu of the Portal.
When you click on it, it should make a request to the endpoint GET /api/${VERSION}/demo.csharp/portal
.
This endpoint returns the client's bundled JavaScript file ServiceConfiguration.bundle.js
that you built at the previous step.
Here is an example of the output:
/******/ (function(modules) { // webpackBootstrap↵/******/ // The module cache↵/******/ var installedModules = {};↵/******/↵/******/ // The require function↵/******/ function __webpack_require__(moduleId) [...]
The Portal will use this response to display the user interface of the service.
MIT © Platform 6