Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axway-flow-sdk

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axway-flow-sdk

SDK for implementing custom flow nodes for API Builder flows

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
77
increased by450%
Maintainers
1
Weekly downloads
 
Created
Source

axway-flow-sdk

SDK for implementing custom flow nodes for API Builder flows

Features

  • CLI tool for starting a new flow-node project
  • SDK for building custom modules for API Builder flows

Install

npm install -g axway-flow-sdk

Generating a new flow-node project

Generates a new flow-node project named "mynode" in the current directory.

axway-flow -n mynode
cd mynode
npm install
npm run build

encodeURI example

const sdk = require('axway-flow-sdk');
exports = module.exports = sdk.init(module)
	.add('encodeURI', {
		name: 'Encode URI',
		icon: 'encode.svg',
		description: 'URI encoder'
	})
	.method('encode', {
		name: 'Encode URI',
		description: 'Encodes a URI by replacing each instance of certain characters with UTF-8 encodings.'
	})
	.parameter('uri', {
		type: 'string',
		description: 'The URI to encode.'
	})
	.outputs('encoded', {
		name: 'Encoded',
		description: 'The encoded URI.',
		conext: '$.encodedURI',
		schema: {
			type: 'string'
		}
	})
	.action((req, cb) => {
		cb.encoded(null, encodeURI(req.params.uri));
	});

Type references

In Axway API Builder, it is possible to reference other types. For example, types can be loaded from ./schemas, registered from models, or registered from service connectors. Any registered schema can be referenced whenever a schema is required.

.parameter('greeting', {
	"$ref": "schema://model/appc.arrowdb/user"
})
.outputs('next', {
	schema: {
		"$ref": "schema://model/appc.arrowdb/user"
	}
})

Testing your flow-node module

The cli will automatically generate a unit test in ./test/test.js. The test will use mocknode to mock an API Builder flow-node.

mocknode(specs) : function

Mocks an API Builder flow-node using the spec generated with NodeBuilder.

Access: public

ParamTypeDescription
specsNodeBuilderThe NodeBuilder object.

Testing a successful output callback: cb.next(null, 'stuff')

This example uses mocha and promises to check that the spec is defined well enough to pass the argument foo to the method method. It also mocks the callback using the spec's defined output, and ensures that the method invokes the correct callback.

const specs = require('../src');
const { mocknode } = require('axway-flow-sdk');

it('describes a test', () => {
	const args = { foo: undefined };
	return mocknode(specs).node('example').invoke('method', args)
		.then((response) => {
			expect(response).to.deep.equal({
				next: [null, 'stuff']
			})
		});
})

Testing an error default callback: cb('invalid argument')

This example is similar to the previous example, save that the expectation is that the method will invoke cb('invalid argument') when given an undefined parameter.

const specs = require('../src');
const { mocknode } = require('axway-flow-sdk');

it('describes a test', () => {
	const args = { foo: undefined };
	return mocknode(specs).node('example').invoke('method', args)
		.then((response) => {
			expect(response).to.deep.equal(['invalid argument'])
		});
})

API Reference

ERROR, Cannot find module.

Author

Axway support@axway.com https://axway.com

License

This code is closed source and Confidential and Proprietary to Axway, Inc. All Rights Reserved. This code MUST not be modified, copied or otherwise redistributed without express written permission of Axway. This file is licensed as part of the Axway Platform and governed under the terms of the Axway license agreement. Your right to use this software terminates when you terminate your Axway subscription.

FAQs

Package last updated on 15 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc