Skip to content

Latest commit

 

History

History
170 lines (114 loc) · 6.94 KB

README.md

File metadata and controls

170 lines (114 loc) · 6.94 KB

verdaccio-redis-storage

All Contributors

npm NPM npm

A Redis based storage plugin for Verdaccio.

Usage

Install

npm install verdaccio-redis-storage

Configuration

store:
  redis-storage:
    host: 127.0.0.1
    port: 6379
    ...

See more in https://github.com/luin/ioredis#connect-to-redis

Note Since v0.2.5, verdaccio-redis-storage changed the redis library from node-redis to ioredis.

About the offline queue

By default, there is no active connection to the Redis server, commands are added to a queue and are executed once the connection is "ready". This is (only) necessary for the verdaccio-redis-storage initialziation, due to the way a verdaccio plugin is being invoked. You should not set the enableOfflineQueue boolean to false in the configuration file.

However, the offline queue feature will be disabled when the first redis connection is ready, to make following web requests fail instantly if a redis connection is down.

Serving tarball

Redis is an in-memory database that is not good at dealing with large tarball files. It's highly recommended to use verdaccio-storage-proxy to decouple the tarball accesses to another storage backend like verdaccio-aws-s3-storage or verdaccio-minio.

Data structure

Content type Redis type Redis key Hash field Note
package list set ve:pkgs -
secret string ve:secret -
token hash ve:token:$user $tokenKey
package.json hash ve:pkg:$packageName package.json
tarball hash ve:pkg:$packageName $fileName base64 encoded

Data are stored with prefix ve: (testve: for test mode).

Dump and restore

With verdaccio-redis CLI, you can exchange data between redis storage and file system.

Dump and restore commmands don't support token yet.

Goto the package folder where you installed the plugin, run ./node_modules/verdaccio-redis-storage/bin/verdaccio-redis.

$ ./node_modules/verdaccio-redis-storage/bin/verdaccio-redis --help
Usage: verdaccio-redis [options] [command]

verdaccio-redis-storage CLI

Options:
  -V, --version            output the version number
  --config <path>          specify the path of Verdaccio configuration file
  --host <host>            Redis host
  --port <port>            Redis port
  --url <url>              Redis URL string
  --socket <socket>        Redis socket string
  --password <password>    Redis password
  --db <db>                Redis db
  --prefix <prefix>        Redis prefix
  -h, --help               display help for command

Commands:
  dump [options] <dir>     dump Redis storage to dir
  restore [options] <dir>  restore Redis storage from dir
  help [command]           display help for command

You can provide the Redis connection by specifying the Verdaccio config path (--config=...), or extra options like --host and --port. By default, it connects to 127.0.0.1:6379.

Dump redis storage to file system

Use the dump command to export redis storage to the file system. The exported folder can be used by Verdaccio's default file storage.

$ ./node_modules/verdaccio-redis-storage/bin/verdaccio-redis dump --help
Usage: verdaccio-redis dump [options] <dir>

dump Redis storage to dir

Options:
  --no-tarball  ignore tarball files
  --dbname      database filename (default: .verdaccio-db.json)
  -h, --help    display help for command

Use --no-tarball option to ignore export tarball files to the file system. See serving tarball for details.

Use --dbname option to specify a different database filename to write. i.e. for Verdaccio S3 storage, the filename is verdaccio-s3-db.json.

Restore redis storage from file system

Use the restore command to import redis storage from the file system.

./node_modules/verdaccio-redis-storage/bin/verdaccio-redis restore --help
Usage: verdaccio-redis restore [options] <dir>

restore Redis storage from dir

Options:
  --no-tarball  ignore tarball files
  --dbname      database filename (default: .verdaccio-db.json)
  --scan        scan package.json to fill database
  -h, --help    display help for command

Use --no-tarball option to ignore import tarball files to the Redis storage. See serving tarball for details.

Use --dbname option to specify a different database filename to read. i.e. for Verdaccio S3 storage, the filename is verdaccio-s3-db.json.

Use --scan option to scan the package.json file of sub-folders to fill the database. A rare usage to convert cached uplink packages to local packages (uplink packages are not stored to database by defaut).

Development

See the verdaccio contributing guide for instructions setting up your development environment. Once you have completed that, use the following npm tasks.

  • npm run build

    Build a distributable archive

  • npm run test

    Run unit test

For more information about any of these commands run npm run ${task} -- --help.

Reference

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Favo Yang

💻

This project follows the all-contributors specification. Contributions of any kind welcome!