asyncapi-topic-parser

0.2.0 • Public • Published

AsyncAPI topic parser

It uses the AsyncAPI topic structure definition to manipulate topics.

Installation

npm install --save asyncapi-topic-parser

Documentation

#parse

It takes a topic in string format and generates an object which describes the topic.

const parser = require('asyncapi-topic-parser');
console.log(parser.parse('hitch.email.1.0.action.user.welcome.send'));
 
// { org: 'hitch',
//   service: 'email',
//   version: '1.0',
//   versions: { major: '1', minor: '0' },
//   type: 'action',
//   resource: 'user.welcome',
//   resources: [ 'user', 'welcome' ],
//   subresource: 'welcome',
//   subresources: [ 'welcome' ],
//   operation: 'send',
//   status: undefined }

#stringify

It takes an object which describes the topic and generates a topic in string format.

const parser = require('asyncapi-topic-parser');
const parsed = {
  org: 'hitch',
  service: 'email',
  version: '1.0',
  versions: { major: '1', minor: '0' },
  type: 'action',
  resource: 'user.welcome',
  resources: [ 'user', 'welcome' ],
  subresource: 'welcome',
  subresources: [ 'welcome' ],
  operation: 'send',
  status: 'done'
};
console.log(parser.stringify(parsed));
 
// hitch.email.1.0.action.user.welcome.send.done

Author/s

Fran Mendez    @fmvilas

Readme

Keywords

Package Sidebar

Install

npm i asyncapi-topic-parser

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • fmvilas