npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ah-resque-ui

v3.0.1

Published

A resque administration website for actionhero

Downloads

171

Readme

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 v28+

  1. install
npm install --save ah-resque-ui
  1. Add this plugin to your ./config/plugins.ts
export const DEFAULT = {
  plugins: () => {
    return {
      "ah-resque-ui": { path: __dirname + "/../../node_modules/ah-resque-ui" },
    };
  },
};
  1. Create a new config file, ./src/config/ah-resque-ui.ts
const namespace = "ah-resque-ui";

declare module "actionhero" {
  export interface ActionheroConfigInterface {
    [namespace]: ReturnType<typeof DEFAULT[typeof namespace]>;
  }
}

export const DEFAULT = {
  [namespace]: () => {
    return {
      // the name of the middleware(s) which will protect all actions in this plugin
      // ie middleware: ['logged-in-session', 'role-admin']
      middleware: [] as string[],
    };
  },
};
  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 { res, req } = connection.rawConnection;
        const credentials = auth(req);
        if (!credentials || credentials.pass !== correctPassword) {
          res.statusCode = 401;
          res.setHeader("WWW-Authenticate", 'Basic realm="Admin Access"');
          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