1.1.3 • Published 5 years ago
localism v1.1.3
Localism
Local development tools. Not for production, just to make you more PRODUCTIVE.
Installation
npm install -g localism
npm install --save localismGetting Started
Just require the module, every method lives at the top level.
const { simpleCache } = require('localism');
const cacheFn = simpleCache({fn: myAsyncFunction });Methods
getFileFromS3({s3Credentials, bucket, key, fileStream, contentType = 'text/plain'})
Retrieves the file from the bucket at the key and writes it to the stream provided.
putFileOnS3({s3Credentials, bucket, key, fileStream, contentType = 'text/plain'})
Places the file into the bucket at the key and reads it from the stream provided.
simpleCache({fn, transformFromFile, fileNameGenerator, cacheDirectoryPath, uuidFileName})
Wraps a given method to create a cache that writes to the local file system. The huge local development advantage is the ability to read and review responses, while keeping the cache from relying on what's in memory.
// This is made for async functions
const cachedFn = simpleCache({fn: myAsyncFunction, cacheDirectoryPath: 'tmp/local/cache'});
const response = await cachedFn({red: 2, green: 6, blue: false});
// The above response will be saved to a file and then accessed from there on future callsContribution Guidelines
Fork the respository and install all the dependencies:
npm installMake sure to run the unit tests (and lint) before committing. Obviously, add to the tests as you make changes:
npm run testFor watch:
npm run test:watch