Skip to content

Commit

Permalink
fixed index handler callback implementation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-viegas committed Jul 20, 2019
1 parent 292630f commit 20e157d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -37,9 +37,9 @@ const storeFunctions = (config) => {
else {
if( event.pathParameters && event.pathParameters.entity ) {
if( event.pathParameters.id )
service.entityRetrieval(event.pathParameters.entity, event.pathParameters.id, callback);
service.entityRetrieval(event.pathParameters.entity, event.pathParameters.id, done);
else
service.entitiesRetrieval(event.pathParameters.entity, callback);
service.entitiesRetrieval(event.pathParameters.entity, done);
}
else
throw new ServerError("Unsupported path", 404);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@jtviegas/store-functions",
"version": "0.0.5",
"version": "0.0.7",
"description": "functions for a data store api",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 3 additions & 8 deletions service.js
Expand Up @@ -68,14 +68,9 @@ const service_module = (config) => {
confirmTable(table, (e) => {
if(e)
callback(e);
else{
store.getObjs(table, (e,d)=>{
if(e)
callback(e);
else
callback(null, d);
});
}
else
store.getObjs(table, callback);

});
logger.debug("[entitiesRetrieval|out]");
}
Expand Down
6 changes: 4 additions & 2 deletions test/test_index.js
Expand Up @@ -75,7 +75,8 @@ describe('index tests', function() {
if(e)
done(e);
else {
expect(d.length).to.equal(config.TEST_ITERATIONS);
let r=JSON.parse(d.body);
expect(r.length).to.equal(config.TEST_ITERATIONS);
done(null);
}
});
Expand All @@ -97,7 +98,8 @@ describe('index tests', function() {
if(e)
done(e);
else {
expect(d).to.eql({'id': 2, 'description': 'xpto' + 2, 'category': 'a' + 2});
let r=JSON.parse(d.body);
expect(r).to.eql({'id': 2, 'description': 'xpto' + 2, 'category': 'a' + 2});
done();
}
});
Expand Down

0 comments on commit 20e157d

Please sign in to comment.