Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fmvilas/node-topic-parser
https://github.com/fmvilas/node-topic-parser
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fmvilas/node-topic-parser
- Owner: fmvilas
- Created: 2017-04-16T18:32:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-17T11:49:03.000Z (over 7 years ago)
- Last Synced: 2024-12-15T05:27:41.743Z (11 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AsyncAPI topic parser
It uses the [AsyncAPI topic structure definition](https://github.com/asyncapi/topic-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.
```js
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 }
```
#### #stringifyIt takes an object which describes the topic and generates a topic in string format.
```js
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](https://www.twitter.com/fmvilas)