persist-store
persist-store
enables you to persist files across data stores (locally, S3, custom data store).
Install
npm install persist-store --save
Usage
const Persist = // Under the hood, persist-store uses Promises, so// custom persisters should implement promises { return Promise } { return Promise } // example optionsconst persist = type: 'local' path: './data/file' type: 's3' bucket: 'a_bucket' key: 'some_prefix/the_key' accessKeyId: '1234' secretAccessKey: '4567' type: 'custom' implementation: persist
If no services are given, only a local persister is created and files are saved in $HOME/.persist
API
store#save(fileName, contents)
Saves a file across all stores
persist
store#load(fileName)
Checks all data stores for the file, makes sure they are all equal, then returns the value
persist
Testing
If you want to mock the S3 persist-store in a test, you can pass localPath
along with bucket
and S3 will use ${localPath}/${bucket}
as a mock S3 bucket
License
MIT