HTTP server exposing ubibot as a ReST service.
Currently alpha code
npm install @numical/ubibot-channel-rest
A channel package that instantiates a server providing ReST endpoints for a multi-user implementation of ubibot.
This is not a standalone library.
It must be used as a dependency in a 'domain' module such as @numical/bankbot:
const { startReST } = require("@numical/ubibot-channel-rest");
const { config } = require("an ubibot domain package");
startReST(config);
The endpoints are:
GET /health
: simple health check; returns HTTP code 200 is ok;POST /chat
: starts a new user session with ubibot;POST /chat/{id}
: continues a user session with ubibot;
This also offers a test runner for the ReST server:
const { testReST } = require("@numical/ubibot-channel-rest");
const { config } = require("an ubibot domain package");
const scriptsDir = path.resolve(...);
testReST("My Domain Tests", config, scriptsDir);
See @numical/ubibot-test for more on using this test runner.
This module exports 2 functions:
###startReST(config)
- instantiates a single-user ubibot and starts a command line interface
arguments
- config (Object) : configuration object created by a domain package; returns
undefined - but a side effect is a spawned http.Server process wrapped by Koa
###testReST(config)
- instantiates a single-user ubibot and runs a test runner for use with @numical/ubibot-test
arguments
- name (String): display name for the test
- config (Object) : configuration object created by a domain package;
- scriptsDir (String) : the fully resolved path of the scripts directory. returns
undefined