Skip to content

Commit

Permalink
Added ability to list all repositories. Endpoint returns an array of …
Browse files Browse the repository at this point in the history
…repository information, in the same order as they are configured.

Call /repositores/ to see the list.
Allows FE to read repositorie for issue #37
  • Loading branch information
jhkuperus committed Mar 20, 2015
1 parent 51787d2 commit fcab23c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cacheEntryRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function CacheEntries (Nocca) {
this.addRecording = addSingleRecording;
this.exportRecordings = exportRecordings;
this.name = function() { return 'memory-entries'; };
this.type = function() { return Nocca.constants.RepositoryType.CACHES; };

this.init = initRestRoutes;

Expand Down
5 changes: 5 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ module.exports = {

FORWARDER_REQUEST_ERROR: 'FORWARDER_REQUEST_ERROR'

},

RepositoryType: {
SCENARIOS: 'SCENARIOS',
CACHES: 'CACHES'
}
};
11 changes: 11 additions & 0 deletions lib/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module.exports = Playback;
function Playback (Nocca) {

this.findMatchingRequest = findMatchingRequest;
this.init = function() {

Nocca.pubsub.publish(Nocca.constants.PUBSUB_REST_ROUTE_ADDED, ['GET:/repositories/', listRepositories]);

};

function findMatchingRequest(reqContext) {

Expand All @@ -18,5 +23,11 @@ function Playback (Nocca) {

return reqContext;
}

function listRepositories(apiReq) {

apiReq.ok().end(JSON.stringify(_.map(Nocca.repositories, function(repo) { return { name: repo.name(), type: repo.type() }; })));

}

}
3 changes: 2 additions & 1 deletion lib/scenarioRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function ScenarioRepository (Nocca) {
self.exportScenarios = exportScenarios;
self.resetScenario = resetScenario;
self.name = function() { return 'memory-scenarios'; };

this.type = function() { return Nocca.constants.RepositoryType.SCENARIOS; };

self.init = function() { importInitialScenarios(); initRestRoutes(); };

// -- Import Data
Expand Down

0 comments on commit fcab23c

Please sign in to comment.