This is demonstrates best-practices for developing a K2 Broker using TypeScript.
- Full object model intellisense for making development easier
- Sample broker code that accesses jsonplaceholder.
- Sample unit tests with mocks and code coverage.
- RollupJS configuration for TypeScript.
This template requires Node.js v12.14.1+ to run.
Install the dependencies and devDependencies:
npm install
Alternatively, use pnpm to reduce the size of the node_modules
directory:
npm install -g pnpm # Only required once
pnpm install
See the documentation for @k2oss/k2-broker-core for more information about how to use the broker SDK package.
To run the unit tests, run:
npm test
pnpm test # Alternative
You can also use a development build, for debugging and coverage gutters:
npm run test:dev
pnpm run test:dev # Alternative
You will find the code coverage results in coverage/index.html.
When you're ready to build your broker, run the following command
npm run build
pnpm run build # Alternative
You will find the results in the dist/index.js.
Once you have a bundled .js file, upload it to your repository (anonymously accessible) and register the service type using the system SmartObject located at System > Management > SmartObjects > SmartObjects > JavaScript Service Provider and run the Create From URL method.
MIT, found in the LICENSE file.