GithubHelp home page GithubHelp logo

simpledb's Introduction

simpledb

If you're using this library, feel free to contact me on twitter if you have any questions! :) @rjrodger

NOTE: this project follows the Open-Open policy - if you submit a pull request or an issue, you get commit rights, so feel free to merge yourself after asking for feedback from the other contribs.

IMPORTANT: YOUR CODE CONTRIBUTIONS (if any) ARE MADE UNDER THE MIT LICENSE. By submitting a pull request or issue you indicate agreement with this condition.

Please open an issue to indicate a release should be published to NPM, and we can discuss.

Current Version: 0.2.0

Tested on: node 0.12.4

A user-friendly fault-tolerant library for Amazon AWS SimpleDB access. The core SimpleDB actions are mapped to functions:

var simpledb = require('simpledb')
var sdb      = new simpledb.SimpleDB({keyid:'YOUR_AWS_KEY_ID',secret:'YOUR_AWS_SECRET_KEY'})

sdb.createDomain( 'yourdomain', function( error ) {

  sdb.putItem('yourdomain', 'item1', {attr1:'one', attr2:'two'}, function( error ) {

    sdb.getItem('yourdomain', 'item1', function( error, result ) {
      console.log( 'attr1 = '+result.attr1 )
      console.log( 'attr2 = '+result.attr2 )
    })
  })
})

Any given SimpleDB request has a non-trivial chance of failing. This library implements the exponential back-off retry algorithm as recommended in the SimpleDB developer guide.

This library depends on the excellent aws-lib module: aws-lib

Key Features:

  • simple API
  • fully configurable
  • detailed logging
  • all request attributes can be overridden
  • fully tested

Core Functions:

  • createDomain ("CreateDomain")
  • domainMetadata ("DomainMetadata")
  • listDomains ("ListDomains")
  • deleteDomain ("DeleteDomain")
  • putItem ("PutAttributes")
  • batchPutItem ("BatchPutAttributes")
  • batchDeleteItem ("BatchDeleteAttributes")
  • getItem ("GetAttributes")
  • deleteItem ("DeleteAttributes")
  • select ("Select")
  • request (any action)

This is still an early version so there's probably some wierdness - use at your risk. Secure connections are not supported on node 0.3.x.

Installation

npm install simpledb

And in your code:

var simpledb = require('simpledb')

Or clone the git repository: git clone git://github.com/rjrodger/simpledb.git

The simpledb module depends on the aws-lib module. npm will install this automatically.

Usage

This module uses the node.js-style callback convention. All functions take a callback function as their last argument. This callback function should accept three arguments:

callback( error, result, meta )

Where error is an object ({Code:'...',Message:'...'}) describing any errors that occured. If the function was successful then error is null.

So, you check if error is null to see if you can continue working:

sdb.listDomains( function( error, result, meta ) {
  if( error ) {
    console.log('listDomains failed: '+error.Message )
  }
  else {
    // do stuff with result, an array of domain names
  }
})

The result parameter contains the results of a successful action and what the result parameter is depends on the action. It could be a string, an array or an object.

The meta parameter contains a description of the request, including the underlying details from Amazon. Take a look with:

console.log( JSON.stringify(meta) )

Conventions

Where possible, the SimpleDB naming style is preserved: CamelCaseBaby. Names of functions and their parameters also mostly match SimpleDB.

The simpledb.SimpleDB wrapper options (maxtry, secure, etc) are not directly related to Amazon, and so have their own names.

It is sometimes necessary to embed meta-directives into the Amazon query or result objects. These non-Amazon attributes always begin with the $ character, but are in CamelCase. For example: $AsArrays.

This wrapper is based on the REST API. I looked at the SOAP API but... yeah. No X.509 for you. Yet.

API

For the API examples, assume the following lines of code at the top of your source code file:

var simpledb = require('simpledb')

var sdb = new simpledb.SimpleDB(
  {keyid:'YOUR_AWS_KEY_ID',secret:'YOUR_AWS_SECRET_KEY'},
  simpledb.debuglogger
)

This gives you the standard wrapper, with a basic debugger that prints to STDOUT.

You should really also read the Amazon SimpleDB documentation so that you understand how SimpleDB works: Amazon SimpleDB Developer Guide

As a get-out-of-jail, you can provide request attribute overrides. You supply these in an optional override argument just before the callback argument. You can use an override on any of the SimpleDB action wrapper functions.

sdb.getItem('domain','itemname', {ConsistentRead:'false'} ,function(err,res,meta){ ... })

In the above code, {ConsistentRead:"false"} is the optional override argument.

simpledb.SimpleDB: simpledb.SimpleDB( options, logger )

  • options: (required) set of options; keyid and secret are required

  • logger: (optional) callback for log events

    var sdb = new simpledb.SimpleDB( options, logger )

Create a new SimpleDB wrapper. The options argument sets general options for the requests. The logger argument receives logging events so that you can debug and/or record SimpleDB interactions.

options: required

  • keyid: (required), your Amazon AWS Key ID
  • secret: (required), your Amazon Secret Key

For further options, see the section on options below

logger: optional

See the section on logging below

createDomain: sdb.createDomain(domain,override,callback)

  • domain: (required) the name of the domain
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Create a domain. A domain is like a SQL table, sort of.

sdb.createDomain('<domain>',function(err,res,meta){
  if( !err ) {
    console.log('Mul-ti-pass!')
  }
}

Where <domain> is the name of your domain.

domainMetadata: sdb.domainMetadata(domain,override,callback)

  • domain: (required) the name of the domain
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Get some statistics about your domain, such as a count of items and how much storage it is using (you pay Amazon for this!).

sdb.domainMetadata('<domain>',function(err,res,meta){
   console.log('Mmm, floor pie! '+JSON.stringify(res) )
}

Where <domain> is the name of your domain.

listDomains: sdb.listDomains(override,callback)

  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Returns a list of your domain names as an array of strings. Restricted to the specified SimpleDB host (default=sdb.amazonaws.com). See the simpledb.SimpleDB options to change this.

sdb.listDomains(function(err,res,meta){
   console.log('You hear that? That's market bacon hitting the pan: '+JSON.stringify(res) )
}

deleteDomain: sdb.deleteDomain(domain,override,callback)

  • domain: (required) the name of the domain
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Delete a domain. Cannot be undone!

sdb.deleteDomain('<domain>',function(err,res,meta){
  if( !err ) {
    console.log('God made the world, but we made the field.')
  }
}

Where <domain> is the name of your domain.

putItem: sdb.putItem(domain,itemname,attrs,override,callback)

  • domain: (required) the name of the domain
  • itemname: (required) the unique name of the item in the domain
  • attrs: (required) the item attributes to store
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Store an item in SimpleDB.

sdb.putItem('<domain>','<itemname>',
  {
    <attr>:'<value>',
    ...
  },
  function(err,res,meta){
    console.log("Memories, you're talking about memories: "+JSON.stringify(res))
  })

Where <itemname> is the unique name of your item, and <attr>:"<value>" are the attribute-value pairs for your item. The value must be either a string or an array of strings.

If you want to use conditional puts, you'll need to add some override values:

sdb.putItem('<domain>','<itemname>',
  {
    <attr1>:'<value>',
    <attr2>:['<value1>','<value2>',...]
    ...
  },
  {
    'Expected.1.Name':'VersionNumber',
    'Expected.1.Value':'1'
  },
  function(err,res,meta){
    console.log("Nobody expects the spanish inquistion! "+JSON.stringify(res))
  })

batchPutItem: sdb.batchPutItem( domain, items, override, callback )

  • domain: (required) the name of the domain
  • items: (required) the list of items to store
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Store multiple items in the same request. This is more efficient. The items argument is an array of item objects. Each item object must have a $ItemName meta-attribute that specifies the name of the item.

sdb.batchPutItem('<domain>',
  [
    { $ItemName:'<itemname1>', <attr>:'<value>', ...},
    { $ItemName:'<itemname2>', <attr>:'<value>', ...}
  ],function(err,res,meta){
    console.log("And what was your ownership share diluted down to?"+JSON.stringify(res))
  })

batchDeleteItem: sdb.batchDeleteItem( domain, items, override, callback )

  • domain: (required) the name of the domain
  • items: (required) the list of items to delete
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Delete multiple items in one request. This is more efficient. The items argument is an array of item objects. Each item object must have a $ItemName meta-attribute that specifies the name of the item.

sdb.batchDeleteItem('<domain>',
  [
    { $ItemName:'<itemname1>', <attr>:'<value>', ...},
    { $ItemName:'<itemname2>', <attr>:'<value>', ...}
  ],function(err,res,meta){
    console.log("Done"+JSON.stringify(res))
  })

getItem: sdb.getItem( domain, itemname, override, callback )

  • domain: (required) the name of the domain
  • itemname: (required) the unique name of the item in the domain
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Get an item from SimpleDB using the item's unique name. The values of the item's attributes are returned as strings. You can provide an $AsArrays meta-directive in the override argument. When true, all attribute values are returned as arrays. As SimpleDb is schemaless, it is not possible to know in advance if an attribute is multi-valued. In the default case, {$AsArrays:false}, multiple values are returned as string, with the value list comma-separated. SimpleDB returns multiple values in alphabetical order.

sdb.getItem('<domain>','<itemname>',function( error , result, meta ){
  console.log("Those are good burgers, Walter: "+JSON.stringify(res))
})

sdb.getItem('<domain>','<itemname>',{$AsArrays:true},function( error, result, meta ){
  console.log("I've been watching television so much the shows are starting to run together: "+JSON.stringify(res))
})

By default, simpledb uses consistent reads. For improved performance, if this is suitable for your application, you can set the consistent option to false when creating simpledb.SimpleDB. Or you can set it on a case-by-case basis, using an override: {ConsistentRead:"false"}

deleteItem: sdb.deleteItem( domain, itemname, attrs, override, callback )

  • domain: (required) the name of the domain
  • itemname: (required) the unique name of the item in the domain
  • attrs: (optional) the attributes to delete
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Delete an item from SimpleDB. The attrs argument is optional, and can be:

  • an array of attribute names: all matching attributes will be deleted
  • an object whose properties are attribute names: attributes of the item will be deleted if they have the same value as the object properties. Values can be either a single string, or an array of string values, in which case all matching attributes are deleted.

If no attributes are specified, the item is completely removed. If present, only the specified attributes are removed. If all the attributes of an item are removed, then it will also be completely deleted.

sdb.deleteItem('<domain>','<itemname>',function( error, result, meta ){
  console.log("Well, Ted, like I said the last time: it won't happen again: "+JSON.stringify(res))
})

sdb.deleteItem('<domain>','<itemname>',[ '<attr>', ... ], function( error, result, meta ){
  console.log("I felt like destroying something beautiful. "+JSON.stringify(res))
})

sdb.deleteItem('<domain>','<itemname>',
  { '<attr1>': '<value1>', 'attr2': ['<value2>, ... ], ... },
  function( error, result, meta ){
    console.log("I don't know what to write about. "+JSON.stringify(res))
  }
)

select: sdb.select( query, override, callback )

  • query: (required) SimpleDB select expression
  • override: (optional) SimpleDB attributes to override function defaults
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Perform a SELECT-style query on a SimpleDB domain. The syntax is almost-but-not-quite SQL. You should read the Amazon documentation: Using Select

The results are returned as an array of items. Each item contains an $ItemName meta-attribute providing you with the name of the item.

If you need to handle NextToken you'll need to do this manually with the override argument. You can get the NextToken from the meta parameter to your callback.

sdb.select("select * from <domain> where <attribute> = '<value>'",function( error, result, meta ){
  console.log("I'll get you, my pretty, and your little dog too! "+JSON.stringify(result)+" "+JSON.stringify(meta))
})

request: sdb.request( action, attrs, callback )

  • action: (required) SimpleDB action
  • attrs: (required) SimpleDB request attributes
  • callback: (required) callback function accepting parameters callback(error, result, metadata)

Make a direct request to SimpleDB. You're on your own! Again, read Amazon SimpleDB Developer Guide Unlike the other functions above, the request function is not a SimpleDB action wrapper. Use it when the wrapper functions have painted themselves into a corner.

sdb.request("<action>",
  {
    <attribute>:"<value>",
    ...
  },
  function( error, result, meta ){
    console.log("Gotta keep 'em separated: "+JSON.stringify(res))
  })

Where <action> is the SimpleDB action, such as GetItem, and <attribute>:"<value>" are the SimpleDB REST request attribute pairs.

client: sdb.client

The aws-lib client object. Use this to send raw requests. Go hardcore.

handle: sdb.handle( start, action, query, tryIndex, last, response, stop, callback, )

  • start: Date object, start time of request
  • action: string, name of SimpleDB action
  • query: full SimpleDB query
  • tryIndex: number of tries attempted, up to maxtry
  • last: true if this is the last request that will be made
  • response: result from SimpleDB
  • stop: stop(true|false), function to stop retries in case of errors
  • callback: action-specific callback, as provided by functions like getItem, putItem, etc.

Replace this with your own implementation to change the handling of SimpleDB responses. Most useful is to modify the response in some way and then call the original function. Also good for testing.

This example counts the number of requests made:

var resultcount = 0

var orighandle = sdb.handle
sdb.handle = function(start,action,query,tryIndex,last,response,stop,callback){
  res.$ResultCount = resultcount++
  orighandle(start,action,query,tryIndex,last,response,stop,callback)
}

Options

The additional options that can be given to simpledb.SimpleDB are:

  • secure: (optional, default=false), if true, use HTTPS
  • consistent: (optional, default=true), if true, ask for consistent reads
  • test: (optional, default=false), if true, don't actually send anything to SimpleDB
  • host: (optional, default=sdb.amazon.com), SimpleDB host
  • path: (optional, default=/), SimpleDB path
  • version: optional), default=2009-04-15, SimpleDB API version
  • maxtry: (optional, default=4), maximum number of retries when SimpleDB fails
  • delaymin: (optional, default=0), minimum delay in milliseconds
  • delayscale: (optional, default=100), delay multiplier, in milliseconds
  • randomdelay: (optional, default=true), apply a random delay multiplier between 0 and 1
  • expbase: (optional, default=4), exponent base, for the formula that calculates delay time when SimpleDB fails
  • nolimit: (optional, default=false), if true, it will return results over the max limit of 2500 with subsequent api requests

Logging

You can provide a logger callback when you are creating the simpledb.SimpleDB object to get notifications of request processing events. A simple logger that prints to STDOUT is provided by simpledb.debuglogger:

var sdb = new simpledb.SimpleDB( {...}, simpledb.debuglogger )

The logger callback accepts the following arguments: logger( type, date, ... )

  • type: string, one of create, request, handle, error, status
  • date: a Date object
  • ...: remaining arguments depend on type

For type=create, fired when the simpledb.SimpleDB object is created, the arguments are:

  • opts: options object
  • awsopts: aws-lib options

For type=request, fired just before a request is made to SimpleDB, the arguments are:

  • start: Date object, start time of request
  • action: string, name of SimpleDB action
  • query: full SimpleDB query

For type=handle, fired after each response from SimpleDB, the arguments are:

  • start: Date object, start time of request
  • action: string, name of SimpleDB action
  • query: full SimpleDB query
  • tryIndex: number of tries attempted, up to maxtry
  • last: true if this is the last request that will be made
  • response: result from SimpleDB

For type=error, fired after any response with an error, the arguments are:

  • start: Date object, start time of request
  • action: string, name of SimpleDB action
  • query: full SimpleDB query
  • tryIndex: number of tries attempted, up to maxtry
  • last: true if this is the last request that will be made
  • retry: true if a retry will be attempted
  • err: the error that occurred, an object like {Code:'...',Message:'...'}, where Code is the Amazon error code
  • res: the result
  • meta: the request meta data

For type=status, fired after each retry, the arguments are:

  • done: true if request has finally succeeded
  • tryIndex: count of attempts
  • last: true if this was the last attempt
  • delay: delay in milliseconds until this attempt
  • err: any error that occurred

Testing

The unit tests use expresso

npm install expresso
npm install eyes

To configure your keys, edit the test/keys.js file. The tests are in test/simpledb.test.js

Amazon AWS SimpleDB

Here's some more information on SimpleDB:

Amazon AWS SimpleDB Developer Guide

simpledb's People

Contributors

ramandeeptrehan avatar richorama avatar rjrodger avatar tracend avatar unitof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simpledb's Issues

Select calls cannot be made in parallel

The results array is global to the module. if a client makes two simultaneous selects, one select return with also include results from the other select.

I suggest scoping results to a function.

putItem() yields invalid signature when character '!' is present in value

The following code makes Amazon respond with HTTP 403 and error code "SignatureDoesNotMatch":

var simpledb = require('simpledb');

sdb = new simpledb.SimpleDB({keyid:'...', secret:'...'});
sdb.putItem('test', 'item01', {my_key:'this character will break the request: !'}, function(err){
  if (err) throw err.Message;
});

When I remove the exclamation mark from the item no error is returned.

docbug: Usage

Small typo:
sdb.listDomains( functions( error, result, meta ) {
if( error ) {
console.log('listDomains failed: '+error.Message )
}
else {
// do stuff with result, an array of domain names
}
})


change functions to function.

Region support

It seems that there is no support for regions.
I tried to init SimpleDB with:
var sdb = new simpledb.SimpleDB(
{
keyid:'xxxxxx',
secret:'xxxx',
region:'eu-west-1'
},
simpledb.debuglogger
);

But it still returns US region data.

parentheses in simpledb 'select' request cause SignatureDoesNotMatch API error

I've found that when I either
a) make a select request (e.g. 'select itemName() from domain') or;
b) make a putItem request that contains parentheses
I get the following error

{ Code: 'SignatureDoesNotMatch',
Message: 'The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.' }

When I remove the parentheses both queries work fine. I'm using Node v0.4.1. Can't seem to figure out what's causing the signature I send over to be created incorrectly.

Any ideas?

Thanks!

-Chris

Empty strings not written to SimpleDb

When using putItem or batchPutItem empty strings are not written to SDB. These writes do not seem to be included in the API request, maybe because "" == false somewhere.

To replicate:

var SimpleDb = require('simpledb');

var sdb = new SimpleDb.SimpleDB({
    keyid:      'keyid',
    secret:     'secret'
});

var fPutGet = function (inItemName, inValue) {

    // Write the item to SDB and read it back
    sdb.putItem(
        'testDomain',
        inItemName,
        { 'someAttribute': inValue },
        function (inError, inResult, inMeta) {

            console.log('putItem done (' + inItemName + ':' + inValue + '), error:', inError);

            sdb.getItem(
                'testDomain',
                inItemName,
                function (inError, inResult, inMeta) {

                    console.log('getItem done (' + inItemName + ':' + inValue + '), result:', inResult);

                }
            );

        }
    );

}

sdb.createDomain(
    'testDomain',
    function () {

        console.log('createDomain done');
        fPutGet('item1', 'not empty');
        fPutGet('item2', '');

    }
);

socket hang up error is not handled

when the http connection (in aws) emits a socket hangup, my application crashes instead of returning or throwing an error .
This is easily reproduced on a long query if there is a long time between a select call and the select call with the "next token".

Support IAM role based authentication

The simpledb library requires users to provide an AWS keyid and secret, while the underlying aws-lib support creating a client without AWS credentuals - in which case it uses IAM role based authentication for running under EC2.

Simpledb should support logging in without specifying AWS credentials using aws-lib IAM role support.

batchPutItems only stores first item

I am trying to write an array of items to SimpleDB via batchPutItems. For some reason, only the first item in the array is stored. All items are well formed, with an $ItemName attribute. Storing every single item with putItem works fine.

Handle network issues gracefully

When I perform an API request and I'm not connected to the internet I get:

Error: ETIMEOUT, Timeout while contacting DNS servers
at Timer.callback (dns.js:38:13)

Ideally timeouts would be passed to our callbacks as an error parameter, I think. And maybe we could set the timeout duration as an option as well? No sense waiting a minute (or whatever the default is) to tell the client that we can't reach SimpleDb.

Thanks again for an excellent module.

package.json is not compatible with npm 0.3.0

As of npm 0.3.0, the package.json file must be strict JSON format, not just a JavaScript object. The items in the array "keywords" should have double quotes instead of single quotes.

npm still at version 0.0.6

npm, as far as I can tell, is still registering the previous version of simpledb. I'd like to take advantage of the newer commands that have been added to the library and still keep my node packages managed via npm. Can this be updated?

Issue when running from AWS console vs. local

I have no issue running the program I had written on my local machine. the simpledb library runs perfect and my app.'s script is running without errors. However when I push this to my AWS machine, i get the following 'error' in the debugger. I am not sure why I get this since its the same exact code and it happens whether i try to list domains or a simple select. I'm confused as to why this is happening.

DEBUG: simpledb: 2014-03-24T03:57:29.499Z create {"keyid":"","secret":"","secure":false,"consistent":true,"test":false,"maxtry":null,"expbase":null,"delaymin":null,"delayscale":null,"randomdelay":null} {"secure":false,"host":"sdb.amazonaws.com","path":"/","version":"2009-04-15","port":80,"nolimit":false,"maxlimit":2500}
util.debug: Use console.error instead
DEBUG: simpledb: 2014-03-24T03:57:29.531Z request 1395633449531 Select {"SelectExpression":"select * from stockfeed_new where idOfTextStatus > '444080819490283521' order by idOfTextStatus asc limit 10","ConsistentRead":"true"}
util.debug: Use console.error instead
DEBUG: simpledb: 2014-03-24T03:57:29.562Z status false 1 false 0 {}
util.debug: Use console.error instead
DEBUG: simpledb: 2014-03-24T03:57:29.891Z status false 2 false 325.94354087486863 {}
util.debug: Use console.error instead
DEBUG: simpledb: 2014-03-24T03:57:30.058Z status false 3 false 165.23593217134476 {}
util.debug: Use console.error instead
DEBUG: simpledb: 2014-03-24T03:57:36.199Z status false 4 true 6134.611403942108 {}

Node.js + Express + simpledb; “TypeError: Cannot read property 'Errors' of null” when trying to list domains

I'm trying to get a very simple test of Amazon SimpleDB running with Node.js/Express. This is the code I'm using (AWS key/secret sanitized, of course):

var express = require('express');
var simpledb = require('simpledb');

var app = express.createServer();
var sdb = new simpledb.SimpleDB(
        {keyid:'MYKEY', secret:'MYSECRET'}, simpledb.debuglogger);

app.get('/', function(req, res) {
        console.log("about to list domains...");
        sdb.listDomains(function(error, result, meta) {
                console.log("listing domains, I think?");
        });
});

app.listen(8888);

This is the error I'm getting:

DEBUG: simpledb:  2012-04-06T01:34:24.856Z create {"keyid":"MYKEY","secret":"MYSECRET","secure":false,"consistent":true,"test":false,"maxtry":null,"expbase":null,"delaymin":null,"delayscale":null,"randomdelay":null} {"secure":false,"host":"sdb.amazonaws.com","path":"/","version":"2009-04-15","port":80}
about to list domains...
DEBUG: simpledb:  2012-04-06T01:34:29.253Z request 1333676069253 ListDomains {}
DEBUG: simpledb:  2012-04-06T01:34:29.387Z handle 1333676069253 ListDomains {"Action":"ListDomains","Version":"2009-04-15","SignatureMethod":"HmacSHA256","SignatureVersion":"2","Timestamp":"2012-04-06T01:34:29.253Z","AWSAccessKeyId":"MYKEY","Signature":"AWSSIGNATURE"} 1 false null

/home/rob/node_modules/simpledb/lib/simpledb.js:136
    if( res.Errors ) {
           ^
TypeError: Cannot read property 'Errors' of null
    at [object Object].handle (/home/rob/node_modules/simpledb/lib/simpledb.js:136:12)
    at /home/rob/node_modules/simpledb/lib/simpledb.js:188:18
    at Parser.<anonymous> (/home/rob/node_modules/simpledb/node_modules/aws-lib/lib/aws.js:81:13)
    at Parser.emit (events.js:67:17)
    at Object.onclosetag (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/xml2js/lib/xml2js.js:120:24)
    at emit (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:148:32)
    at emitNode (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:152:3)
    at closeTag (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:226:5)
    at Object.write (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/sax/lib/sax.js:567:29)
    at Parser.<anonymous> (/home/rob/node_modules/simpledb/node_modules/aws-lib/node_modules/xml2js/lib/xml2js.js:145:29)

I'm pretty new to Node.js, the simpledb module and SimpleDB itself, but this to me seems like a bug in the simpledb module. I can't figure out what I'm doing wrong otherwise - I'm confident my key/secret are valid (as I've tested with both set invalid, separately and together, and I get back actual errors from Amazon that indicate the key/secret are invalid).

This error, though, has me stumped. Any ideas?

Make all requests cancellable

Hi!

It would be very nice, if the library will provide some means to cancel requests. Exponential back-off algo is really cool, but sometime it is absolutely necessary to be able to cancel too long running request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.