Skip to content

codeanker/feathers-bee

Repository files navigation

feathers-bee

Greenkeeper badge Code Climate Dependency Status Download Status

Installation

npm install feathers-bee --save

Documentation

Setup

app.use('/bee', bee({
  service: app.service('serviceToLog'), // add your service
  name: 'example'
}));

Plugin Args

  • service: The service to log
  • name: Name of the Queue
  • queue: Settings of the Queue
  • paginate: The default pagenate stuff

Bee Queue events

The bee-queue events are implemented as custom feathers events

Usage

  • Create a new job: call create at the bee service to create a new job
  • Get a job: call get with a job id to get a job
  • Find jobs: call find at the bee service to find the waiting jobs
    • change type with params

Complete Example

Here's an example of a Feathers server that uses feathers-bee.

const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const handler = require('feathers-errors/handler');
const bodyParser = require('body-parser');
const memory = require('feathers-memory');
const bee = require('feathers-bee');

// Create a feathers instance.
const app = feathers()
  .configure(socketio())
  .configure(rest())
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({extended: true}));

// Create any service you like.
app.use('/messages', memory({
  paginate: {
    default: 2,
    max: 4
  },
  id:'_id'
}));

// Create bee service
app.use('/bee', bee({
  service: app.service('messages'), // add your service
  name: 'example', // name
  queue: {}, // queue settings
  paginate: {
    default: 2,
    max: 4
  }
}));

// A basic error handler, just like Express
app.use(handler());

// Start the server
var server = app.listen(3030);
server.on('listening', function () {
  console.log('Feathers running on 127.0.0.1:3030');
});

License

Copyright (c) 2017

Licensed under the MIT license.