npm.io
2.2.4 • Published 4 years ago

express-git-self-update

Licence
idc
Version
2.2.4
Deps
0
Size
24 kB
Vulns
0
Weekly
0

express-git-self-update

Express route to upgrade self from git remote when endpoint is called.

Usage

const Express = require('express');
const SelfUpdate = require('express-git-self-update');

const app = Express();

app.use(Express.json());

const options = {
  compareBody: body => body.key === 'SuperSecretExampleKey',
  onUpdatedCommand: 'systemctl restart example-program.service'
};

app.post('/webhook/selfupdate', SelfUpdate(options));

Options

Pass options when initializing the middleware to customize it's behavior. Available options:

  • compareNpmVersion [boolean] (default: true) - Only update when remote package.json version is higher than the local.
  • runNpmInstall [boolean] (default: true) - Automatically run npm install after update.
  • compareBody [object => boolean] - Function to compare incoming body. Won't update if function returns false.
  • compareQuery [object => boolean] - Function to compare incoming query parameters. Won't update if function returns false.
  • onUpdate [() => void] - Function to call after program has been updated.
  • onUpdateCommand [string] - Shell command to execute after program has been updated. (Runs after onUpdate.)
  • groupingTime [number] (default: 0) - Minimum amount of time in millis to wait after starting a self updating check before allowing a new check. Requests that are sent within this time frame will be grouped together, that is, their response will be the same and returned when the running check finishes.

Keywords