mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-13 09:46:20 +00:00
c6e1f96f5f80a9b87f008bac15c58505229b812c
minimal-connector
Prerequisites
nodeandnpminstalled- a backend, which is running locally (on http://localhost:3000)
How to get started
To install all required npm packages:
npm install
To prepare the script to be executed, run:
npm run build
To start the plugin, you need to execute the code in "CLI" script:
node lib/cli.js run <backendURL> <pluginName> <routeName> <URL> <port>
e.g.:
node lib/cli.js run http://localhost:3000 minimal-plugin minimalPlugin http://localhost 4000
Creating your own plugin
- Modify the default values in
cli.tsto your needs:- update the name
- update the port
- update the route
- update your request and response names (You need these in a bit)
- Rename the
minimal-plugin.tsand theMinimalPluginclass to a more suitable name and adjust the imports in other files - Delete the
sumfunction inminimal-plugin.tsand write your own logic inside theonRouteInvokefunction - Define the layout of your http requests and responses inside the
/plugin/protocolfolder. The names of the interfaces need to be the same as the request and response names you defined in thecli.ts
Code structure
Folder src contains:
- Reference implementations for CLI and a plugin
- /cli.ts
- minimal CLI to start your connector, that uses CLI-args, so that there are no hard coded values for configuration
- will execute the specified connectors and push the data to the backend
- /common.ts blank file for commonly used values across files to put in
- /plugin/minimal-connector.ts minimal plugin class with some example logic
- /plugin/protocol/request.ts the interface for any incoming http requests
- /plugin/protocol/response.ts the interface for responses by the plugin to the backend
- /plugin/protocol/tsconfig.json required by schema generator
Description
Languages
TypeScript
85.8%
HTML
7.5%
SCSS
4%
JavaScript
1.6%
Dockerfile
0.4%
Other
0.5%