Comparing version 0.0.10 to 0.0.11
'use strict'; | ||
/** | ||
* Represents an Output through 6px. | ||
* | ||
* Outputs are basically images that are created through 6px. It contains all of | ||
* the information needed to build the image. | ||
*/ | ||
var Output = function(refs) { | ||
@@ -15,2 +21,11 @@ | ||
/** | ||
* Resize an image based off of the size object. | ||
* | ||
* If you just pass one value (width or height) the omitted value is assumed based on the aspect ratio. | ||
* | ||
* @method resize | ||
* @param {Object} size [description] | ||
* @chainable | ||
*/ | ||
Output.prototype.resize = function(size) { | ||
@@ -27,2 +42,10 @@ | ||
/** | ||
* Add some filters to an image | ||
* | ||
* @method filter | ||
* @param {String} type The filter name. For instance: 'sepia' | ||
* @param {Mixed} value The value or strength that you are looking for. | ||
* @chainable | ||
*/ | ||
Output.prototype.filter = function(type, value) { | ||
@@ -47,2 +70,12 @@ | ||
/** | ||
* The location that we will attempt to save this to. | ||
* | ||
* The most convenient would be to save simply to 6px's CDN. To do that, just | ||
* pass in '6px'. | ||
* | ||
* @method url | ||
* @param {String} location The location to save this to. | ||
* @chainable | ||
*/ | ||
Output.prototype.url = function(location) { | ||
@@ -56,2 +89,9 @@ | ||
/** | ||
* Rotate an image | ||
* | ||
* @method rotate | ||
* @param {Object} options Pass in degrees. Pass in the optional background color as `color` (it assumes 'transparent') | ||
* @chainable | ||
*/ | ||
Output.prototype.rotate = function(options) { | ||
@@ -68,2 +108,9 @@ | ||
/** | ||
* Crop the image | ||
* | ||
* @method crop | ||
* @param {Object} position Contains x, y, width, and height | ||
* @chainable | ||
*/ | ||
Output.prototype.crop = function(position) { | ||
@@ -79,2 +126,10 @@ | ||
/** | ||
* Place one input ontop of another. Watermarking. | ||
* | ||
* @method layer | ||
* @param {String} refName The name of the input you want to put on top. | ||
* @param {Object} options The options object that contains (all optional): opacity, x, y, width, height | ||
* @chainable | ||
*/ | ||
Output.prototype.layer = function(refName, options) { | ||
@@ -103,2 +158,11 @@ | ||
/** | ||
* The mime type to save this out as | ||
* | ||
* It assumes 'image/png'. | ||
* | ||
* @method type | ||
* @param {String} mime The mime type to save as | ||
* @chainable | ||
*/ | ||
Output.prototype.type = function(mime) { | ||
@@ -112,2 +176,8 @@ | ||
/** | ||
* Called by the SDK to make sense of all of the data the user inputted. | ||
* | ||
* @method export | ||
* @return {Object} | ||
*/ | ||
Output.prototype.export = function() { | ||
@@ -114,0 +184,0 @@ |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var version = require('../package.json').version; | ||
@@ -27,4 +29,2 @@ | ||
* Reset the request | ||
* | ||
* @method reset | ||
*/ | ||
@@ -38,2 +38,13 @@ _6px.prototype.reset = function() { | ||
/** | ||
* Load an input. | ||
* | ||
* Define a name and then where the file is. Could be a local file or a file | ||
* somewhere online. | ||
* | ||
* @method load | ||
* @param {String} name The name we want to give our image. | ||
* @param {Mixed} path The location or the file itself. Can be a Buffer, relative path, or location on the web. | ||
* @chainable | ||
*/ | ||
_6px.prototype.load = function(name, path) { | ||
@@ -46,2 +57,11 @@ | ||
/** | ||
* Create a new output. | ||
* | ||
* Will create an Output object and add it to the list of outputs. | ||
* | ||
* @method output | ||
* @param {Object} refs A key/value pair. Key refers to the ref (input name). Value is the filename you wish to have. If false, we will generate one for you. | ||
* @returns {Output} An output object | ||
*/ | ||
_6px.prototype.output = function(refs) { | ||
@@ -72,3 +92,3 @@ | ||
/** | ||
* Send the request up to the server for processing. | ||
* Send the request up to 6px for processing. | ||
* | ||
@@ -153,8 +173,3 @@ * @method save | ||
/** | ||
* Use this to set up your account with apiKey, etc | ||
* | ||
* Must be called before any other functions. | ||
*/ | ||
// Not used yet | ||
px.openSocket = function() { | ||
@@ -164,2 +179,8 @@ | ||
/** | ||
* Utility to parse through an input. | ||
* | ||
* @param {Mixed} input The image data. Location on the web or Buffer. | ||
* @param {Function} cb The callback function with the results. | ||
*/ | ||
px.parseInput = function(input, cb) { | ||
@@ -191,3 +212,3 @@ | ||
* | ||
* Basically a wrapper that sends an XHR request to the 6px API server | ||
* Basically a wrapper that sends a request to the 6px API server | ||
*/ | ||
@@ -237,2 +258,5 @@ px.sendToServer = function(data, fn) { | ||
/** | ||
* Figures out the image type a file is from a buffer. | ||
*/ | ||
px.findImageType = function(buffer) { | ||
@@ -255,2 +279,7 @@ var int32View = new Int32Array(buffer); | ||
/** | ||
* Converts a buffer into a dataURI | ||
* | ||
* @param {Buffer} buffer The buffer to convert. | ||
*/ | ||
px.toDataURI = function(buffer) { | ||
@@ -260,25 +289,46 @@ return 'data:' + px.findImageType(buffer) + ';base64,' + buffer.toString('base64'); | ||
// Not used yet | ||
px.callbacks = { | ||
express: function(req, res) { | ||
} | ||
}; | ||
px.version = version; | ||
/** | ||
* Initializes our px object and makes sure we set the right variables. | ||
* | ||
* Expects an object with all of these defined: apiKey, userId, apiSecret | ||
*/ | ||
module.exports = function(data) { | ||
if (px.userData) { | ||
throw '6px: Init must only be called once!'; | ||
if (!data) { | ||
var data = {}; | ||
} | ||
if (!data.apiKey) { | ||
var env = process.env, | ||
apiKey = (data.apiKey || env['PX_API_KEY']), | ||
apiSecret = (data.apiSecret || env['PX_API_SECRET']), | ||
userId = (data.userId || env['PX_USER_ID']); | ||
if (!apiKey) { | ||
throw '6px: apiKey is required!'; | ||
} | ||
if (!data.userId) { | ||
if (!userId) { | ||
throw '6px: userId is required!'; | ||
} | ||
if (!data.apiSecret) { | ||
if (!apiSecret) { | ||
throw '6px: apiSecret is required!'; | ||
} | ||
px.userData = data; | ||
px.userData = { | ||
userId: userId, | ||
apiSecret: apiSecret, | ||
apiKey: apiKey | ||
}; | ||
return px; | ||
}; |
{ | ||
"name": "6px", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "NodeJS SDK for 6px.io", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
499942
485
2