Skip to content

Commit

Permalink
made proxy optional
Browse files Browse the repository at this point in the history
  • Loading branch information
baelter committed Apr 10, 2014
1 parent d62b391 commit c80bbed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-rsimulatorjs",
"description": "Grunt plugin for rsimulatorjs-server",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/baelter/grunt-rsimulatorjs",
"author": {
"name": "Anders Bälter",
Expand Down
29 changes: 13 additions & 16 deletions tasks/rsimulatorjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,29 @@ module.exports = function(grunt) {
port: 9005,
rootPath: './mocked-rest-api',
useRootRelativePath: true
},
proxy: {
port : 9004,
pathnameOnly : true,
router : {
'/service' : '127.0.0.1:' + 9005,
'' : '127.0.0.1:' + 9001
}
}
}),
serverOptions = {
simulatorConfig: options.simulator,
proxyConfig: {
simulatorConfig: options.simulator
};
if (options.proxy) {
serverOptions.proxyConfig = {
port: options.proxy.port || 9004,
options: {
pathnameOnly: options.proxy.pathnameOnly || true,
router: options.proxy.router
}
}
};
}
grunt.verbose.writeln('Grunt-rsimulatorjs options: ', JSON.stringify(options));
rsimulatorjsServer(serverOptions);
grunt.log.ok('Started rsimulator on ' + serverOptions.simulatorConfig.port + ' with proxy on ' + serverOptions.proxyConfig.port + ' with the following routes:');
for(route in serverOptions.proxyConfig.options.router) {
grunt.log.ok(route + ' : ' + serverOptions.proxyConfig.options.router[route]);
grunt.log.ok('Started rsimulator on ' + serverOptions.simulatorConfig.port);
if (serverOptions.proxyConfig) {
grunt.log.ok(' with proxy on ' + serverOptions.proxyConfig.port + ' with the following routes:');

for(route in serverOptions.proxyConfig.options.router) {
grunt.log.ok(route + ' : ' + serverOptions.proxyConfig.options.router[route]);
}
}
});

};
};

0 comments on commit c80bbed

Please sign in to comment.