@platform/npm.express
Express middleware for working with NPM.
Last updated 6 days ago by philcockfield .
MIT · Original npm · Tarball · package.json
$ cnpm install @platform/npm.express 
SYNC missed versions from official npm registry.

Module License: MIT NPM banner

Express middleware for working with NPM.

 

 

Example

Run the example directly in node:

yarn example

or run the example within docker:

yarn dbuild
cd examples
docker-compose up

see the /examples/docker-compose.yml file for example configuration and command-line arguments to pass to the container.

 

Middleware

To use the express middleware directly

import * as express from 'express';
import { router } from '@platform/npm.express';

const getContext = async () => {
  return {
    name: 'my-module',                // Name of the NPM module being managed.
    downloadDir: '/download/folder',  // Directory where latest NPM version is downloaded to.
  };
};

const routes = router.create({ getContext });
const server = express().use(routes);
server.listen(1234);

Routes

GET   /status
POST  /update
POST  /start
POST  /stop

Query-string parameters for /status:

{
  versions?=<number>    // Include version history. If number (n) provided returns only the latest (n) versions.
  size?=<boolean>       // Include size of the download folder.
}

Body parameters for /update:

{ 
  restart?: boolean;                        // Restart the service once updated (default: true)
  version?: string | 'latest';              // Specific version to install (default: 'latest')
  prerelease?: boolean | 'alpha' | 'beta',  // Install pre-release version, eg 1.2.0-beta.0 (default: false)
  reset?: boolean,                          // Delete existing download before installing (default: false)
  dryRun?: boolean,                         // Perform all checks, but don't actually change anything.
}

Body parameters for /start:

{ restart?: boolean }

Command-Line Arguments

To configure the module when working with it as Docker container pass the following command-line arguments:

    --npm-module='<string>'             # (required) The name of the NPM module being managed.
    --dir='<string>'                    # (required) Path to the download directory.
    --port='<number>'                   # (optional) Port to run the management server on.
    --prerelease='<boolean|alpha|beta>' # (optional) Whether pre-release versions should be used (default:false).
    --url-prefix='<string>'             # (optional) Prefix to prepend URL's with, eg /foo => GET /foo/status
    --update                            # (optional) Flag indicating if update performed at startup (default:false).
    --npm-token                         # (optional) An NPM authorization token if working with private modules.

see the /examples/docker-compose.yml file for example configuration.

.env

These same arguments can alternatively be specified as environment variables, see /example/env/main.env and the env_file reference in docker-compose.yml for example.

NPM_MODULE=           --npm-module
NPM_DIR=              --dir
NPM_PORT=             --port
NPM_PRERELEASE=       --prerelease
NPM_URL_PREFIX=       --url-prefix
NPM_UPDATE=           --update
NPM_TOKEN=            --npm-token

Any values passed explicitly to the command will override the environment variables.

Private NPM Packages

Follow the instructions on NPM "Using private packages in a CI/CD workflow" to create a token to access your private modules:

npm token create --read-only

Alternatively tokens can be created within the npmjs.com adminitration UI.
Pass the token as either a command-line argument or an environment variable at startup.

Current Tags

  • 0.1.143                                ...           latest (6 days ago)

92 Versions

  • 0.1.143                                ...           6 days ago
  • 0.1.139                                ...           22 days ago
  • 0.1.135                                ...           2 months ago
  • 0.1.131                                ...           3 months ago
  • 0.1.129                                ...           3 months ago
  • 0.1.128                                ...           4 months ago
  • 0.1.127                                ...           4 months ago
  • 0.1.126                                ...           4 months ago
  • 0.1.125                                ...           5 months ago
  • 0.1.123                                ...           6 months ago
  • 0.1.122                                ...           6 months ago
  • 0.1.121                                ...           6 months ago
  • 0.1.120                                ...           6 months ago
  • 0.1.119                                ...           6 months ago
  • 0.1.112                                ...           7 months ago
  • 0.1.111                                ...           8 months ago
  • 0.1.108                                ...           9 months ago
  • 0.1.105                                ...           9 months ago
  • 0.1.101                                ...           9 months ago
  • 0.1.99                                ...           10 months ago
  • 0.1.98                                ...           10 months ago
  • 0.1.97                                ...           10 months ago
  • 0.1.96                                ...           10 months ago
  • 0.1.95                                ...           10 months ago
  • 0.1.94                                ...           10 months ago
  • 0.1.93                                ...           10 months ago
  • 0.1.91                                ...           10 months ago
  • 0.1.90                                ...           a year ago
  • 0.1.89                                ...           a year ago
  • 0.1.86                                ...           a year ago
  • 0.1.84                                ...           a year ago
  • 0.1.81                                ...           a year ago
  • 0.1.78                                ...           a year ago
  • 0.1.75                                ...           a year ago
  • 0.1.74                                ...           a year ago
  • 0.1.72                                ...           a year ago
  • 0.1.71                                ...           a year ago
  • 0.1.70                                ...           a year ago
  • 0.1.69                                ...           a year ago
  • 0.1.66                                ...           a year ago
  • 0.1.63                                ...           a year ago
  • 0.1.61                                ...           a year ago
  • 0.1.57                                ...           a year ago
  • 0.1.56                                ...           a year ago
  • 0.1.55                                ...           a year ago
  • 0.1.54                                ...           a year ago
  • 0.1.51                                ...           a year ago
  • 0.1.50                                ...           a year ago
  • 0.1.49                                ...           a year ago
  • 0.1.48                                ...           a year ago
  • 0.1.47                                ...           a year ago
  • 0.1.45                                ...           a year ago
  • 0.1.44                                ...           a year ago
  • 0.1.43                                ...           a year ago
  • 0.1.41                                ...           a year ago
  • 0.1.40                                ...           a year ago
  • 0.1.38                                ...           a year ago
  • 0.1.36                                ...           a year ago
  • 0.1.34                                ...           a year ago
  • 0.1.33                                ...           2 years ago
  • 0.1.32                                ...           2 years ago
  • 0.1.31                                ...           2 years ago
  • 0.1.30                                ...           2 years ago
  • 0.1.27                                ...           2 years ago
  • 0.1.26                                ...           2 years ago
  • 0.1.23                                ...           2 years ago
  • 0.1.22                                ...           2 years ago
  • 0.1.21                                ...           2 years ago
  • 0.1.20                                ...           2 years ago
  • 0.1.19                                ...           2 years ago
  • 0.1.18                                ...           2 years ago
  • 0.1.17                                ...           2 years ago
  • 0.1.16                                ...           2 years ago
  • 0.1.15                                ...           2 years ago
  • 0.1.14                                ...           2 years ago
  • 0.1.13                                ...           2 years ago
  • 0.1.12                                ...           2 years ago
  • 0.1.11                                ...           2 years ago
  • 0.1.10                                ...           2 years ago
  • 0.1.9                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 10
Last Month 21
Dependencies (8)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |