{"_id":"storage-s3","_rev":"30-821f9f6578327e3a55059b7f5b81fc72","name":"storage-s3","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"storage-s3","version":"0.1.0","keywords":["aws","s3","storage","byu"],"author":{"name":"Gary Crye","email":"garygsc@gmail.com"},"license":"Apache-2.0","_id":"storage-s3@0.1.0","maintainers":[{"name":"garygsc","email":"garygsc@gmail.com"}],"homepage":"https://github.com/byu-oit/storage-s3#readme","bugs":{"url":"https://github.com/byu-oit/storage-s3/issues"},"dist":{"shasum":"c1e18c6b0a6c4e2421a46c71f9bbecd22022edc6","tarball":"https://registry.npmjs.org/storage-s3/-/storage-s3-0.1.0.tgz","integrity":"sha512-yvdJhN+ylnZt4eEYQ+7ha8THpP29WjLvvcfsEgUK1EB50IbLRpaOrNU6coKkaq+lkWe+QkoIzNO3TnZTQwq9Jw==","signatures":[{"sig":"MEQCIGyJXMm0YRNZV2Uuvaq9dx+8Rr3PyrYrJoDWMfHrXL7CAiBSSCD4FWlLc+7Yw+LJFal66QPI9nldNwBtzungQgbW8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","gitHead":"5d45f2a7b2dce0732d2bc62df83fce9f43c918b4","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"garygsc","email":"garygsc@gmail.com"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/byu-oit/storage-s3.git","type":"git"},"_npmVersion":"5.3.0","description":"A small module for storing values in AWS S3","directories":{},"_nodeVersion":"7.4.0","dependencies":{"aws-sdk":"^2.92.0"},"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/storage-s3-0.1.0.tgz_1501536713613_0.9686400014907122","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"storage-s3","version":"0.1.1","keywords":["aws","s3","storage","byu"],"author":{"name":"Gary Crye","email":"garygsc@gmail.com"},"license":"Apache-2.0","_id":"storage-s3@0.1.1","maintainers":[{"name":"garygsc","email":"garygsc@gmail.com"},{"name":"arasmus8","email":"arasmus8@gmail.com"},{"name":"gi60s","email":"james.speirs@gmail.com"},{"name":"brettbeatty","email":"brettbeatty@gmail.com"},{"name":"thatjoemoore","email":"npm@thatjoemoore.com"},{"name":"mhailstone","email":"matthew.hailstone@gmail.com"},{"name":"saholman","email":"spencer.a.holman@gmail.com"},{"name":"pauldeden","email":"byu-oit-npmjs@byu.edu"}],"homepage":"https://github.com/byu-oit/storage-s3#readme","bugs":{"url":"https://github.com/byu-oit/storage-s3/issues"},"dist":{"shasum":"1b64e32071f1d0bda04b67b3638a49e001f47ce9","tarball":"https://registry.npmjs.org/storage-s3/-/storage-s3-0.1.1.tgz","integrity":"sha512-jUNnVu4GGzPRiopz7swUQdzV2A4agNKHRDt/ngS0JDbTM6wghiV0EVX5thgOLQoqqPBJUDMFS+gLZm7ZXy3dcA==","signatures":[{"sig":"MEQCIFjuCQ2ay01We+rY0CSVSGNQE3KtlVnOYNTVyanULPmqAiAYfzkZVN1FNlg5MQgYGHec/o+Qpu+JFd3FETP+cfXJew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","gitHead":"f8a62a4f37d56547be052b15464d944d126986ef","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"garygsc","email":"garygsc@gmail.com"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/byu-oit/storage-s3.git","type":"git"},"_npmVersion":"5.3.0","description":"A small module for storing values in AWS S3","directories":{},"_nodeVersion":"7.4.0","dependencies":{"aws-sdk":"^2.92.0"},"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/storage-s3-0.1.1.tgz_1501538533989_0.9178623310290277","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-07-31T21:31:54.594Z","modified":"2026-07-06T18:17:10.143Z","0.1.0":"2017-07-31T21:31:54.594Z","0.1.1":"2017-07-31T22:02:15.237Z"},"bugs":{"url":"https://github.com/byu-oit/storage-s3/issues"},"author":{"name":"Gary Crye","email":"garygsc@gmail.com"},"license":"Apache-2.0","homepage":"https://github.com/byu-oit/storage-s3#readme","keywords":["aws","s3","storage","byu"],"repository":{"url":"git+https://github.com/byu-oit/storage-s3.git","type":"git"},"description":"A small module for storing values in AWS S3","maintainers":[{"email":"scott_hutchings@byu.edu","name":"yoshutch"},{"email":"lehi_alcantara@byu.edu","name":"lehinpm"},{"email":"it@byu.edu","name":"oscea"},{"email":"stuft2@protonmail.com","name":"stuft2"},{"email":"matthew.hailstone@gmail.com","name":"mhailstone"},{"email":"arasmus8@gmail.com","name":"arasmus8"},{"email":"garygsc@gmail.com","name":"garygsc"},{"email":"github@snelg.com","name":"snelg"},{"email":"danielduraesm@gmail.com","name":"gholl0"},{"email":"developertools@byu.edu","name":"byu-oit-bot"},{"email":"micah.weatherhead@gmail.com","name":"mjweather"},{"email":"jvisker@byu.edu","name":"jvisker"}],"readme":"# storage-s3\r\nA small module for backing up values in AWS S3. Useful in the event of a server crash or just as a way to maintain state over time.\r\n\r\nThis module maintains an object called 'storage' locally and backs up each user-specified property of that object to S3.\r\nEach value of storage[`object_name`] in memory will have an associated `object_name`.json file in S3.\r\n\r\n**setup** establishes S3 configuration and can initialize local values from S3.\r\n\r\n**getData** returns value from memory.\r\n\r\n**setData** updates a value in S3 and local memory.\r\n\r\n**refresh** can update local memory from S3.\r\n\r\n## Usage\r\n\r\n#### setup\r\nInitializes S3 bucket name and AWS region. Can get initial values from S3 for local memory.\r\n\r\nParameters:\r\n* **bucket_name** (string) - _Required_ - Name of S3 bucket to use\r\n* **object_names_to_get_on_setup** (array of strings) \r\n* **region** (string) - AWS region, defaults to `process.env.REGION`, then `us-west-2`\r\n\r\n```js\r\nconst storage = require('storage-s3');\r\nstorage.setup('some-bucket-name', ['missions', 'logs']);\r\n```\r\n\r\nReturns a Promise upon successful setup.\r\n\r\nIn [mocha](https://www.npmjs.com/package/mocha) testing setups, something like this might be common:\r\n```js\r\nconst storage = require('storage-s3');\r\n\r\ndescribe('Main set of tests', function () {\r\n  before(done => {\r\n    /* Set up local test server */\r\n    \r\n    // Set up storage\r\n    storage.setup('some-bucket-name', ['missions', 'logs'])\r\n        .then(() => done());\r\n  });\r\n  \r\n  /* Some tests */\r\n});\r\n```\r\n\r\n#### getData\r\nA synchronous function that returns a clone of storage[`object_name`] from local memory.\r\n\r\nParameters:\r\n* **object_name** (string) - _Required_\r\n\r\n```js\r\n/* After already calling storage.setup() at some point */\r\n\r\nconst missions = storage.getData('missions');\r\n```\r\n\r\n#### setData\r\nAn asynchronous function that updates `object_name`.json in S3, then updates storage[`object_name`] locally.\r\nReturns a promise.\r\n\r\nParameters:\r\n* **updated_object** (any type serializable to JSON) - _Required_ - The value to save\r\n* **object_name** (string) - _Required_\r\n\r\n```js\r\n/* After already calling storage.setup() at some point */\r\n\r\nconst missions = storage.getData('missions'); //Some array for example purposes\r\nconst some_new_value = {};\r\nmissions.push(some_new_value);\r\n\r\nstorage.setData(missions, 'missions')\r\n    .then(() => console.log('Yay!'));\r\n```\r\n\r\n#### refresh\r\nAn asynchronous function that pulls from S3 and updates local memory.\r\nFor each value in `object_names`, **refresh** will attempt to get `object_name`.json from the S3 bucket specified upon setup and then to update storage[`object_name`].\r\nReturns a Promise.\r\n\r\nParameters:\r\n* **object_names** (array of strings) - _Required_\r\n\r\n```js\r\n/* After already calling storage.setup() at some point */\r\n\r\nstorage.refresh(['missions', 'logs']);\r\n```\r\n","readmeFilename":"README.md"}