Skip to content

K2Documentation/K2Documentation.Samples.JavascriptBroker.WorkflowRESTAPI

Repository files navigation

K2 TypeScript Broker Template

This template demonstrates best-practices for developing a K2 Broker using TypeScript.

Features

  • Full object model intellisense for making development easier
  • Sample broker code that accesses jsonplaceholder.
  • Sample unit tests with mocks and code coverage.
  • Vite configuration for TypeScript.

Getting Started

This template requires Node.js v22.5.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.

Running Unit Tests

To run the unit tests, run:

npm test
pnpm test # Alternative

You will find the code coverage results in coverage/index.html.

Building your bundled JS

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.

Creating a service type

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.

License

MIT, found in the LICENSE file.

www.k2.com

Migration from Ava to Vitest

If you used a previous version of this template and want to migrate to Vitest, please review the Migration.md guide.

About

Sample project demonstrating how to interact with the Workflow REST API using a JSSP service broker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •