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

@bonliva/agendash

v6.0.1

Published

A modern dashboard for Agenda.js with Pagination and Search capabilities

Downloads

114

Readme

Agendash

A Dashboard for Agenda.


Features

  • Job status auto-refreshes: 60-second polling by default.
  • Schedule a new job from the UI.
  • Dive in to see more details about the job, like the json data.
  • Requeue a job. Clone the data and run immediately.
  • Delete jobs. Useful for cleaning up old completed jobs.
  • Search jobs by name and metadata. Supports querying by Mongo Object Id.
  • Pagination
  • Responsive UI

Screenshots

Dashboard

Auto-refresh list of jobs


Create jobs

See job details, requeue or delete jobs


Search by name, metadata, job status

Search for a job by name or metadata


Responsive UI

Mobile UI small devices

Mobile UI extra small devices


Troubleshooting

Index for sorting

It may be required to create the following index for faster sorting (see #24)

db.agendaJobs.ensureIndex({
    "nextRunAt" : -1,
    "lastRunAt" : -1,
    "lastFinishedAt" : -1
}, "agendash")

Roadmap

  • [ ] Get more test coverage
  • [ ] Add middlewares for fastify, and other express-like libraries
  • [ ] You decide! Submit a feature request

Install

npm install --save agendash

Note: Agendash requires mongodb version >2.6.0 to perform the needed aggregate queries. This is your mongo database version, not your node package version! To check your database version, connect to mongo and run db.version().

Middleware usage

Express

Agendash provides Express middleware you can use at a specified path, for example this will make Agendash available on your site at the /dash path. Note: Do not try to mount Agendash at the root level like app.use('/', Agendash(agenda)).

var express = require("express");
var app = express();

// ... your other express middleware like body-parser

var Agenda = require("agenda");
var Agendash = require("agendash");

var agenda = new Agenda({ db: { address: "mongodb://127.0.0.1/agendaDb" } });
// or provide your own mongo client:
// var agenda = new Agenda({mongo: myMongoClient})

app.use("/dash", Agendash(agenda));

// ... your other routes

// ... start your server

By mounting Agendash as middleware on a specific path, you may provide your own authentication for that path. For example if you have an authenticated session using passport, you can protect the dashboard path like this:

app.use(
  "/dash",
  function (req, res, next) {
    if (!req.user || !req.user.is_admin) {
      res.send(401);
    } else {
      next();
    }
  },
  Agendash(agenda)
);

Other middlewares will come soon in the folder /lib/middlewares/. You'll just have to update the last line to require the middleware you need:

app.use(
  "/agendash",
  Agendash(agenda, {
    middleware: "connect",
  })
);

Note that if you use a CSRF protection middleware like csurf, you might need to configure it off for Agendash-routes.

Hapi

A minimum Node.js version 12 is required for @hapi/hapi dependency.

npm i @hapi/inert @hapi/hapi
const agenda = new Agenda().database(
  "mongodb://127.0.0.1/agendaDb",
  "agendaJobs"
);

const server = require("@hapi/hapi").server({
  port: 3002,
  host: "localhost",
});
await server.register(require("@hapi/inert"));
await server.register(
  Agendash(agenda, {
    middleware: "hapi",
  })
);

await server.start();

Then browse to http://localhost:3002/.

Koa

npm i koa koa-bodyparser koa-router koa-static
const agenda = new Agenda().database(
  "mongodb://127.0.0.1/agendaDb",
  "agendaJobs"
);

const Koa = require("koa");
const app = new Koa();
const middlewares = Agendash(agenda, {
  middleware: "koa",
});
for (const middleware of middlewares) {
  app.use(middleware);
}

await app.listen(3002);

Then browse to http://localhost:3002/.

Fastify

npm i fastify
const agenda = new Agenda().database(
  "mongodb://127.0.0.1/agendaDb",
  "agendaJobs"
);

const Fastify = require("fastify");
const fastify = new Fastify();

fastify.register(
  Agendash(
    agenda, 
    { middleware: "fastify" }
  );
);

await fastify.listen(3002);

Then browse to http://localhost:3002/.

Standalone usage

Agendash comes with a standalone Express app which you can use like this:

./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002

or like this, for default collection agendaJobs and default port 3000:

./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb

If you are using npm >= 5.2, then you can use npx:

npx agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002

Then browse to http://localhost:3002/.

Docker usage

Agendash can also be run within a Docker container like this:

docker run -p 3000:3000 \
  --env MONGODB_URI=mongo://myUser:myPass@myHost/myDb \
  --env COLLECTION=myAgendaCollection agenda/agendash

Then browse to http://localhost:3000/.