1.2.3 • Published 3 years ago

nice-commander v1.2.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Nice Commander

CI

NiceCommander runs scheduled and one-off tasks in your Node.js server with a nice UI

Quick Start

Requirements

  • Redis Server for distributed locking
  • MySQL Server for its task and task-run database
  • Amazon CloudWatch Logs Access to store logs

Define your tasks

Create a directory dedicated to your tasks. Create one or many files that export task definitions. Task definitions must conform to the TaskDefinition TypeScript interface.

// tasks/simple.js
/**
 * Using JSDoc you can type the exported task
 * @type {import("nice-commander").TaskDefinition}
 */
module.exports = {
  name: "my-task",
  async run() {
    console.log("my-task is running");
  },
  timeoutAfter: "2 seconds",
};

If you are using TypeScript you can import the TaskDefinition interface and type your task default export with it.

Add NiceCommander to your Express server

NiceCommander is an Express middleware. Create an instance of NiceCommander and pass required configurations for MySQL and Redis as well as the path you want the UI to be accessible from under mountPath.

import express from "express";
import path from "path";
import AWS from "aws-sdk";
import { createMiddleware } from "nice-commander";

const app = express();

const mountPath = "/nice-commander";
const { middleware } = createMiddleware({
  taskDefinitionsDirectory: path.resolve(__dirname, "tasks"),
  mountPath,
  redisConnectionOptions: {
    /* Redis Config */
  },
  sqlConnectionOptions: {
    /* DB Config */
  },
  awsRegion: "us-east-2",
  awsCredentials: new AWS.Credentials({
    accessKeyId: "xxx",
    secretAccessKey: "xxx",
  }),
});
app.use(mountPath, middleware);

app.listen(3000);
1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago