node immerdu
immerdu for node.
Installation
npm install immerdu
Usage
var nacl = var immerdu = var server = 'http://localhost:5984'var username = 'my-account'var filename = '/path/to/an/image.jpg' api
API
Sign Up
Create permit. If the database does not exist, it gets created. If no
accountKey
is given, a new key gets created.
server
: couchdb server urlusername
: account nameaccountKey
: account key pair (optional. if given, only public key required)
callback(err, response)
is called with permit id
, dbKey
and accountKey
on success:
ok: true id: '3d132659-0b26-4f50-92c5-de4c63ffa3c5' accountKey: publicKey: ... // Uint8Array with 32-byte public key secretKey: ... // Uint8Array with 32-byte secret key dbKey: publicKey: ... // Uint8Array with 32-byte public key secretKey: ... // Uint8Array with 32-byte secret key
Sign In
Open immerdu database.
server
: couchdb server urlusername
: account nameaccountKey
: account key pair (only secret key required)
callback(err, response)
is called with the database key pair on success:
publicKey: ... // Uint8Array with 32-byte public key secretKey: ... // Uint8Array with 32-byte secret key
Upload
Import an image.
server
: couchdb server urlusername
: account namedbKey
: database key pair (only public key required)filename
: filename of the imageoptions.overwrite
: reimport existing imagesoptions.exclude
: array of versions which should not be imported
callback(err, response)
is called with the photo id on success:
ok: true id: 'de59be4c5a2e0ec09246b7210dfd6d5634421188'
Thumbs
Retrieve an index with thumbnails.
server
: couchdb server urlusername
: account namedbKey
: database key pair (both public and secret keys are required)size
: thumbnails size can bex256
or256x256
options
: CouchDB view query options, exceptstartkey
andendkey
callback(err, response)
is called with the thumbnails view response on
success:
total_rows: 2 offset: 1 rows: id: 'photo/de59be4c5a2e0ec09246b7210dfd6d5634421188' key: kz8O8lMMAs1nQYIgckje4FLMDVqJaePyUnsG2v9OT3M=', x256' 2014:11:12 13:04:00' ], value: { photoKey: 'aEOUhJwLn4OTMdzGa3bbK5L6BqI2w21vYIt4KuiayzM=', image: { format: 'jpeg', width: 384, height: 256, buffer: ... // Buffer with image data } } } ]}
Images
Retrieve photos.
server
: couchdb server urlusername
: account namedbKey
: database key pair (both public and secret keys are required)ids
: photo id or array of photo idssize
: image size can be1920x1080
ororiginal
callback(err, response)
is called with the images view response on success:
total_rows: 1 offset: 0 rows: id: 'photo/de59be4c5a2e0ec09246b7210dfd6d5634421188' key: Xz65xL8uqkKx26ea8l/ff0Pb1DMOb7WJoj9qC/WAMEw=', de59be4c5a2e0ec09246b7210dfd6d5634421188' value: photoKey: 'FRZRp7SpK84KSe9DhjEq2ZaOE+FoBz3rcZ7KB3Iruig=' image: format: 'jpeg' width: 600 height: 400 buffer: ... // Buffer with image data
Tests
Run the testsuite with npm test
or a single test with node test/lib/test-signin.js
(c) 2014 Johannes J. Schmidt