fix: should now compile and work

This commit is contained in:
Wieland Schoebl
2020-07-13 16:22:09 +02:00
parent 8f62b0faa0
commit 96e977b365
5 changed files with 830 additions and 473 deletions

View File

@@ -37,3 +37,4 @@ Folder `src` contains:
* [/plugin/minimal-connector.ts](src/plugin/minimal-plugin.ts) minimal plugin class with some example logic
* [/plugin/protocol/request.ts](src/plugin/protocol/request.ts) the interface for any incoming http requests
* [/plugin/protocol/response.ts](src/plugin/protocol/response.ts) the interface for responses by the plugin to the backend
* [/plugin/protocol/tsconfig.json](src/plugin/protocol/response.ts) required by schema generator

1215
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -19,24 +19,23 @@
"push": "git push && git push origin \"v$npm_package_version\""
},
"dependencies": {
"@openstapps/api": "0.16.0",
"@openstapps/core": "0.27.0",
"@openstapps/core-tools": "0.8.0",
"@openstapps/logger": "0.4.0",
"@types/node": "12.7.1",
"commander": "3.0.1",
"express": "4.17.0",
"express-promise-router": "3.0.3",
"@openstapps/api": "0.22.0",
"@openstapps/core": "0.35.0",
"@openstapps/core-tools": "0.14.0",
"@openstapps/logger": "0.5.0",
"express": "4.16.4",
"commander": "5.1.0",
"ts-node": "8.3.0"
},
"devDependencies": {
"@openstapps/configuration": "0.21.1",
"@types/express": "4.17.1",
"@openstapps/configuration": "0.24.0",
"@types/node": "12.7.1",
"@types/express": "4.16.1",
"conventional-changelog-cli": "2.0.23",
"prepend-file-cli": "1.0.6",
"rimraf": "3.0.0",
"tslint": "5.19.0",
"typedoc": "0.15.0",
"typescript": "3.6.2"
"typedoc": "0.16.11",
"typescript": "3.7.5"
}
}

View File

@@ -17,7 +17,7 @@ import {HttpClient} from '@openstapps/api/lib/http-client';
import {PluginClient} from '@openstapps/api/lib/plugin-client';
import {Converter} from '@openstapps/core-tools/lib/schema';
import {Logger} from '@openstapps/logger';
import * as commander from 'commander';
import {Command} from 'commander';
import {readFileSync} from 'fs';
import {join, resolve} from 'path';
import {MinimalPlugin} from './plugin/minimal-plugin';
@@ -31,38 +31,35 @@ process.on('unhandledRejection', (error) => {
throw error;
});
commander
const program = new Command()
.version(pluginVersion)
.command('run')
.option('-b <backenUrl>', 'URL of the StApps backend deployment', 'http://localhost:3000')
.option('-n <name>', 'The name of the plugin', 'minimal-plugin') // TODO: adjust default
.option('-r <routeName>', 'The name of the route', 'minimalPlugin') // TODO: adjust default
.option('-u <url>', 'The url of the plugin', 'http://localhost') // TODO: adjust default
.option('-b, --backend-url <string>', 'URL of the StApps backend deployment', 'http://localhost:3000')
.option('-n, --plugin-name <string>', 'The name of the plugin', 'minimal-plugin') // TODO: adjust default
.option('-r, --route-name <string>', 'The name of the route', 'minimalPlugin') // TODO: adjust default
.option('-u, --url <string>', 'The url of the plugin', 'http://localhost') // TODO: adjust default
.option('-p, --port <number>', 'The port of the plugin', '4000') // TODO: adjust default
.parse(process.argv);
// create an instance of the PluginClient
const pluginClient = new PluginClient(new HttpClient(), program.backendUrl);
// create an instance of your plugin
const plugin = new MinimalPlugin(
// tslint:disable-next-line:no-magic-numbers
.option('-p <port>', 'The port of the plugin', 4000) // TODO: adjust default
.action(async (backendUrl: string, name: string, routeName: string, url: string, port: number) => {
Number.parseInt(program.port, 10), program.pluginName, program.url, `/${program.routeName}`, program.backendUrl,
new Converter(resolve(__dirname, '..', 'src', 'plugin', 'protocol')), // an instance of the converter. Required
// because your requests and response schemas are defined in the plugin. The path should lead to your request and
// response interfaces
'SCMinimalRequest', // the name of the request interface TODO: adjust
'SCMinimalResponse', // the name of the response interface TODO: adjust
JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'))
.toString()).version, // get the version of the plugin from the package.json
);
// create an instance of the PluginClient
const pluginClient = new PluginClient(new HttpClient(), backendUrl);
// create an instance of your plugin
const plugin = new MinimalPlugin(port, name, url, `/${routeName}`, backendUrl,
new Converter(resolve(__dirname, '..', 'src/plugin', 'protocol')), // an instance of the converter. Required
// because your requests and response schemas are defined in the plugin. The path should lead to your request and
// response interfaces
'SCMinimalRequest', // the name of the request interface TODO: adjust
'SCMinimalResponse', // the name of the response interface TODO: adjust
JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'))
.toString()).version, // get the version of the plugin from the package.json
);
pluginClient.registerPlugin(plugin)
.then(() => {
Logger.ok('done.');
})
.catch((err: Error) => {
throw err;
});
pluginClient.registerPlugin(plugin)
.then(() => {
Logger.ok('done.');
})
.catch((err: Error) => {
throw err;
});
commander.parse(process.argv);

View File

@@ -0,0 +1,3 @@
{
"extends": "./node_modules/@openstapps/configuration/tsconfig.json"
}