https://github.com/openupm/verdaccio-redis-storage
A Redis based storage plugin for Verdaccio.
https://github.com/openupm/verdaccio-redis-storage
hacktoberfest redis verdaccio verdaccio-plugin verdaccio-redis-storage
Last synced: about 2 months ago
JSON representation
A Redis based storage plugin for Verdaccio.
- Host: GitHub
- URL: https://github.com/openupm/verdaccio-redis-storage
- Owner: openupm
- License: bsd-3-clause
- Created: 2020-07-01T17:59:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-24T18:07:25.000Z (over 1 year ago)
- Last Synced: 2025-04-14T07:04:18.117Z (about 2 months ago)
- Topics: hacktoberfest, redis, verdaccio, verdaccio-plugin, verdaccio-redis-storage
- Language: TypeScript
- Homepage:
- Size: 2.08 MB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# verdaccio-redis-storage
[](#contributors-)
  
A Redis based storage plugin for Verdaccio.
## Usage
Install
```bash
npm install verdaccio-redis-storage
```Configuration
```yaml
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](https://github.com/luin/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](https://github.com/openupm/verdaccio-storage-proxy) to decouple the tarball accesses to another storage backend like [verdaccio-aws-s3-storage](https://github.com/verdaccio/monorepo/tree/master/plugins/aws-s3-storage) or [verdaccio-minio](https://github.com/barolab/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`.
```sh
$ ./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 specify the path of Verdaccio configuration file
--host Redis host
--port Redis port
--url Redis URL string
--socket Redis socket string
--password Redis password
--db Redis db
--prefix Redis prefix
-h, --help display help for commandCommands:
dump [options] dump Redis storage to dir
restore [options] 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.
```sh
$ ./node_modules/verdaccio-redis-storage/bin/verdaccio-redis dump --help
Usage: verdaccio-redis dump [options]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](#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.
```sh
./node_modules/verdaccio-redis-storage/bin/verdaccio-redis restore --help
Usage: verdaccio-redis restore [options]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](#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](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md) 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
- [generator-verdaccio-plugin](https://github.com/verdaccio/generator-verdaccio-plugin), verdaccio plugin generator based in [Yeoman](http://yeoman.io/) aims to help to scaffold plugins development.
- [verdaccio-minio](https://github.com/barolab/verdaccio-minio), a good example of verdaccio storage plugin.## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!