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

feathers-rabbit-queue

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feathers-rabbit-queue

A Feathers service addapter for RabbitMQ based on rabbit-queue

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
Maintainers
3
Weekly downloads
 
Created
Source

feathers-rabbit-queue

A Feathers amqp service adapter for Rabbit Queue.

$ npm install --save feathers-rabbit-queue

API

configure(options)

Configure RabbitMQ with Feathers application as new provider.

Options:

  • uri (required) - Connection uri to RabbitMQ
  • prefetch (optional, default: 1) - Prefetch from queue
  • prefix (optional) - Prefix all queues with an application name
  • socketOptions (optional, default: {}) - Socket Options will be passed as a second param to amqp.connect and from there to the socket library (net or tls)
  • queue (optional, default: {retries: 3, retryDelay: 1000, logEnabled: true}) - Queue options
  • reconnectDelay (optional, default: 1000) - Delay before next reconnect attempt
  • logger (optional, default: console) - Output logger

Example

Here's a example of configuration.

const compress = require('compression');
const helmet = require('helmet');
const cors = require('cors');

const feathers = require('@feathersjs/feathers');
const configuration = require('@feathersjs/configuration');
const express = require('@feathersjs/express');
const rabbitConfigure = require('feathers-rabbit-queue').configure;

const app = express(feathers());

// Load app configuration
app.configure(configuration());
// Enable security, CORS, compression, favicon and body parsing
app.use(helmet());
app.use(cors());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({extended: true}));

// Set up Plugins and providers
app.configure(express.rest());
app.configure(
  rabbitConfigure({
    uri: 'amqp://user:pass@host:5672',
    queueName: 'custom-queue-name',
    logger: console
  })
);

// Configure a middleware for 404s and the error handler
app.use(express.notFound());
app.use(express.errorHandler({logger}));

Send custom message through RabbitMQ.

Create

async function customFunctionWithAppReference(app) {
  try {
    const result = await app.rabbit.createMessage({path: 'path/to/somewhere', method: 'create', body: {}});
    console.log('Got result:', result);
  } catch (error) {
    console.log('Got error:', error);
  }
}

Patch

async function customFunctionWithAppReference(app) {
  try {
    const result = await app.rabbit.createMessage({
      path: 'path/to/somewhere/id-to-patch',
      method: 'patch',
      body: 'id-to-patch',
      data: {
        attribute: 'value'
      }
    });
    console.log('Got result:', result);
  } catch (error) {
    console.log('Got error:', error);
  }
}

Remove

async function customFunctionWithAppReference(app) {
  try {
    const result = await app.rabbit.createMessage({
      path: 'path/to/somewhere/id-to-remove',
      method: 'remove',
      body: 'id-to-remove',
      query: {
        attribute: 'value'
      }
    });
    console.log('Got result:', result);
  } catch (error) {
    console.log('Got error:', error);
  }
}

Message can be send to another Queue.

async function customFunctionWithAppReference(app) {
  try {
    const result = await app.rabbit.createMessage({queueName: 'another-custom-queue', path: 'example/id-of-this-example', method: 'update', body: {}});
    console.log('Got result:', result);
  } catch (error) {
    console.log('Got error:', error);
  }
}

License

MIT

Authors

Keywords

FAQs

Package last updated on 24 Jan 2019

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