Skip to content

Commit

Permalink
i like the list of ids
Browse files Browse the repository at this point in the history
  • Loading branch information
chelm committed Oct 21, 2014
1 parent 28579ce commit 5cf9acb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
17 changes: 17 additions & 0 deletions controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ var Controller = function( ckan ){
});
};

controller.listall = function(req, res){
ckan.find(req.params.id, function(err, data){
if (err) {
res.send( err, 500);
} else {
// Get the item
ckan.getAll( data.host, req.query, function( error, list ){
if (error) {
res.send( error, 500 );
} else {
res.json( list );
}
});
}
});
};

controller.findResource = function(req, res){
ckan.find(req.params.id, function(err, data){
if (err) {
Expand Down
16 changes: 16 additions & 0 deletions models/ckan.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ var ckan = function( koop ){
};

ckan.ckan_path = '/api/3/action/package_show';
ckan.ckan_list_path = '/api/3/action/package_list';

ckan.getAll = function( host, options, callback ){
var self = this;

var url = host + self.ckan_list_path,
result, links = [];
request.get(url, function(err, data, response ){
if (err) {
callback(err, null);
} else {
result = JSON.parse(response).result;
callback( null, result );
}
});
};

// got the service and get the item
ckan.getResource = function( host, id, options, callback ){
Expand Down
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
'post /ckan': 'register',
'get /ckan': 'list',
'get /ckan/:id': 'find',
'get /ckan/:id': 'listall',
'get /ckan/:id/:item.:format': 'findResource',
'get /ckan/:id/:item': 'findResource',
'post /ckan/:id/:item': 'findResource',
Expand Down

0 comments on commit 5cf9acb

Please sign in to comment.