项目作者: codeanker

项目描述 :
Bee Queue as feathers-plugin
高级语言: JavaScript
项目地址: git://github.com/codeanker/feathers-bee.git
创建时间: 2017-09-04T14:15:51Z
项目社区:https://github.com/codeanker/feathers-bee

开源协议:MIT License

下载


feathers-bee

Greenkeeper badge
Code Climate
Dependency Status
Download Status

Installation

  1. npm install feathers-bee --save

Documentation

Setup

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

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.

  1. const feathers = require('feathers');
  2. const rest = require('feathers-rest');
  3. const socketio = require('feathers-socketio');
  4. const handler = require('feathers-errors/handler');
  5. const bodyParser = require('body-parser');
  6. const memory = require('feathers-memory');
  7. const bee = require('feathers-bee');
  8. // Create a feathers instance.
  9. const app = feathers()
  10. .configure(socketio())
  11. .configure(rest())
  12. .use(bodyParser.json())
  13. .use(bodyParser.urlencoded({extended: true}));
  14. // Create any service you like.
  15. app.use('/messages', memory({
  16. paginate: {
  17. default: 2,
  18. max: 4
  19. },
  20. id:'_id'
  21. }));
  22. // Create bee service
  23. app.use('/bee', bee({
  24. service: app.service('messages'), // add your service
  25. name: 'example', // name
  26. queue: {}, // queue settings
  27. paginate: {
  28. default: 2,
  29. max: 4
  30. }
  31. }));
  32. // A basic error handler, just like Express
  33. app.use(handler());
  34. // Start the server
  35. var server = app.listen(3030);
  36. server.on('listening', function () {
  37. console.log('Feathers running on 127.0.0.1:3030');
  38. });

License

Copyright (c) 2017

Licensed under the MIT license.