1.0.0 • Published 3 years ago

@artie-owlet/amqp-routing-match v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

amqp-routing-match

CI Coverage Lint


Install

npm install @artie-owlet/amqp-routing-match

Usage

topic

import { TopicPattern } from '@artie-owlet/amqp-routing-match';

const serviceV1 = new TopicPattern('service.v1.*');
if (serviceV1.match('service.v1.log')) {
    // do smth
}

const serviceAll = new TopicPattern('service.#');
if (serviceAll.match('service.v1.log')) {
    // do smth
}

headers

import { HeadersPattern } from '@artie-owlet/amqp-routing-match';

const test1 = new HeadersPattern({
    'x-match': 'all',
    app: 'test',
    version: 1,
});

if (test1.match({
    app: 'test',
    version: 1,
})) {
    // do smth
}

const errorOrBeta = new HeadersPattern({
    'x-match': 'any',
    log: 'error',
    scope: 'beta',
});

if (errorOrBeta.match({
    log: 'error',
    scope: 'release',
})) {
    // do smth
}

if (errorOrBeta.match({
    log: 'debug',
    scope: 'beta',
})) {
    // do smth
}