Skip to content

Commit

Permalink
Merge pull request #12 from ph0bos/partial-response
Browse files Browse the repository at this point in the history
Partial response
  • Loading branch information
ph0bos committed Nov 1, 2015
2 parents aac8cca + e63311f commit 9cda29f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ var buildOptions = function(options) {
var config = konfig({ path: options.configPath || process.cwd() + '/config' });

// Default options
options.server = options.server || { port: process.env.PORT };
options.debug = options.debug || false;
options.discoverable = options.discoverable || false;
options.monitorsPath = options.monitorsPath || 'monitors';
options.controllersPath = options.controllersPath || 'controllers';
options.callerPath = path.dirname(caller(2));
options.serviceName = pkgInfo.name;
options.serviceBasePath = 'services';
options.zookeeper = { connectionString: 'localhost:2181', retry: { count: 5 } };
options.server = options.server || { port: process.env.PORT };
options.debug = options.debug || false;
options.discoverable = options.discoverable || false;
options.monitorsPath = options.monitorsPath || 'monitors';
options.controllersPath = options.controllersPath || 'controllers';
options.callerPath = path.dirname(caller(2));
options.serviceName = pkgInfo.name;
options.serviceBasePath = 'services';
options.zookeeper = { connectionString: 'localhost:2181', retry: { count: 5 } };
options.partialResponseQuery = options.partialResponseQuery || 'fields';

// Return now if we have no config
if (!config.app) {
Expand Down
6 changes: 3 additions & 3 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ module.exports = function (app, options) {
// Parse application/json
app.use(bodyParser.json());

// Partial Response
app.use(partialRes({ query: options.partialResponseQuery }));

// Starter routes (e.g. actuator)
app.use('/' + options.serviceName, enrouten({ directory: '../controllers' }));

// Implementor routes
app.use('/' + options.serviceName, enrouten({ directory: path.resolve(options.callerPath, options.controllersPath) }));

// Partial Response
app.use(partialRes({ query: options.partialResponseQuery || 'filter' }));

// Make service discoverable?
if (options.discoverable) {
zoologist.on('ready', function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-microservice-starter",
"version": "0.5.7",
"version": "0.5.8",
"description": "An express-based Node.js API bootstrapping module for microservices.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9cda29f

Please sign in to comment.