ah-resque-ui
A resque administration website for actionhero
Last updated 2 months ago by evantahler .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ah-resque-ui 
SYNC missed versions from official npm registry.

AH-RESQUE-UI

A resque administration website for actionhero

Build Status NPM Version

https://raw.githubusercontent.com/evantahler/ah-resque-ui/master/images/overview.png https://raw.githubusercontent.com/evantahler/ah-resque-ui/master/images/workers.png https://raw.githubusercontent.com/evantahler/ah-resque-ui/master/images/failed.png https://raw.githubusercontent.com/evantahler/ah-resque-ui/master/images/delayed.png

Setup for ActionHero v20+

  1. install
npm install --save ah-resque-ui
  1. Add this plugin to your ./config/plugins.ts
export const DEFAULT = {
  plugins: (config) => {
    return {
      "ah-resque-ui": { path: __dirname + "/../../node_modules/ah-resque-ui" },
    };
  },
};
  1. Create a new config file, ./src/config/ah-resque-ui.ts
export const DEFAULT = {
  "ah-resque-ui": (config) => {
    return {
      // the name of the middleware(s) which will protect all actions in this plugin
      // ie middleware: ['basic-auth', 'role-admin']
      middleware: null,
    };
  },
};
  1. visit http://localhost:8080/resque

Routes

This plugin will inject routes into your application. The routes are equivalent to:


get: [
  { path: '/resque/packageDetails',       action: 'resque:packageDetails'    },
  { path: '/resque/redisInfo',            action: 'resque:redisInfo'         },
  { path: '/resque/resqueDetails',        action: 'resque:resqueDetails'     },
  { path: '/resque/queued',               action: 'resque:queued'            },
  { path: '/resque/loadWorkerQueues',     action: 'resque:loadWorkerQueues'  },
  { path: '/resque/resqueFailedCount',    action: 'resque:resqueFailedCount' },
  { path: '/resque/resqueFailed',         action: 'resque:resqueFailed'      },
  { path: '/resque/delayedjobs',          action: 'resque:delayedjobs'       },
],

post: [
  { path: '/resque/removeFailed',            action: 'resque:removeFailed'            },
  { path: '/resque/retryAndRemoveFailed',    action: 'resque:retryAndRemoveFailed'    },
  { path: '/resque/removeAllFailed',         action: 'resque:removeAllFailed'         },
  { path: '/resque/retryAndRemoveAllFailed', action: 'resque:retryAndRemoveAllFailed' },
  { path: '/resque/forceCleanWorker',        action: 'resque:forceCleanWorker'        },
  { path: '/resque/delQueue',                action: 'resque:delQueue'                },
  { path: '/resque/delDelayed',              action: 'resque:delDelayed'              },
  { path: '/resque/runDelayed',              action: 'resque:runDelayed'              },
]

};

Authentication Via Middleware

This package exposes some potentially dangerous actions which would allow folks to see user data (if you keep such in your task params), and modify your task queues. To protect these actions, you should configure this package to use action middleware which would restrict these actions to only certain clients.

The most basic middleware would be one to enforce a Basic Auth Password:

npm install basic-auth --save

// File: src/initializers/basic-auth-middleware.js
import { Initializer, api, action } from "actionhero";
import auth from "basic-auth";

export class BasicAuthInitializer extends Initializer {
  constructor() {
    super();
    this.name = "basic-auth";
  }

  async initialize() {
    const correctPassword = process.env.BASIC_AUTH_PASSWORD;
    const middleware = {
      name: "basic-auth",
      global: false,
      priority: 1000,
      preProcessor: (data) => {
        if (!correctPassword) {
          throw "basic auth password not set up in BASIC_AUTH_PASSWORD env";
        }
        const credentials = auth(connection.rawConnection.req);
        if (!credentials || credentials.pass !== correctPassword) {
          connection.rawConnection.res.statusCode = 401;
          connection.rawConnection.res.setHeader(
            "WWW-Authenticate",
            'Basic realm="Admin Access"'
          );
          connection.rawConnection.res.end("Access denied");
          data.toRender = false;
        }
      },
    };

    action.addMiddleware(middleware);
  }
}

Now you can apply the basic-auth middleware to your actions to protect them.

To inform ah-resque-ui to use a middleware determined elsewhere like this, set api.config.ah-resque-ui.middleware = ['basic-auth'] in the provided configuration file.

Testing & Developing

You will need 2 terminals:

  • Start the actionhero server
    • npm run dev
  • In another shell, run the webpack to regenerate your changes
    • npm run ui:watch

Now visit http://localhost:8080/resque in your browser

Thanks

Current Tags

  • 2.0.4                                ...           latest (2 months ago)
  • 0.5.3                                ...           next (3 years ago)

24 Versions

  • 2.0.4                                ...           2 months ago
  • 2.0.3                                ...           2 months ago
  • 2.0.2                                ...           3 months ago
  • 2.0.1                                ...           3 months ago
  • 2.0.0                                ...           3 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           9 months ago
  • 0.6.0                                ...           2 years ago
  • 0.5.4                                ...           3 years ago
  • 0.5.3                                ...           3 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (22)

Copyright 2014 - 2016 © taobao.org |