0.1.169 • Published 3 years ago

@platform/npm.express v0.1.169

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

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.

0.1.169

3 years ago

0.1.168

3 years ago

0.1.165

3 years ago

0.1.167

3 years ago

0.1.158

3 years ago

0.1.159

3 years ago

0.1.157

3 years ago

0.1.154

3 years ago

0.1.156

3 years ago

0.1.155

3 years ago

0.1.153

3 years ago

0.1.152

3 years ago

0.1.151

3 years ago

0.1.150

3 years ago

0.1.149

3 years ago

0.1.148

3 years ago

0.1.146

3 years ago

0.1.143

3 years ago

0.1.139

4 years ago

0.1.135

4 years ago

0.1.131

4 years ago

0.1.129

4 years ago

0.1.128

4 years ago

0.1.127

4 years ago

0.1.126

4 years ago

0.1.125

4 years ago

0.1.123

4 years ago

0.1.122

4 years ago

0.1.121

4 years ago

0.1.120

4 years ago

0.1.119

4 years ago

0.1.112

4 years ago

0.1.111

4 years ago

0.1.108

4 years ago

0.1.105

4 years ago

0.1.101

4 years ago

0.1.98

4 years ago

0.1.99

4 years ago

0.1.97

4 years ago

0.1.96

4 years ago

0.1.95

4 years ago

0.1.94

4 years ago

0.1.93

4 years ago

0.1.91

4 years ago

0.1.90

4 years ago

0.1.86

4 years ago

0.1.89

4 years ago

0.1.84

4 years ago

0.1.81

4 years ago

0.1.78

4 years ago

0.1.75

4 years ago

0.1.74

4 years ago

0.1.72

4 years ago

0.1.71

4 years ago

0.1.70

4 years ago

0.1.69

4 years ago

0.1.66

5 years ago

0.1.63

5 years ago

0.1.61

5 years ago

0.1.57

5 years ago

0.1.56

5 years ago

0.1.55

5 years ago

0.1.54

5 years ago

0.1.51

5 years ago

0.1.50

5 years ago

0.1.49

5 years ago

0.1.48

5 years ago

0.1.47

5 years ago

0.1.45

5 years ago

0.1.44

5 years ago

0.1.43

5 years ago

0.1.41

5 years ago

0.1.40

5 years ago

0.1.38

5 years ago

0.1.36

5 years ago

0.1.34

5 years ago

0.1.33

5 years ago

0.1.32

5 years ago

0.1.31

5 years ago

0.1.30

5 years ago

0.1.27

5 years ago

0.1.26

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago