Skip to content

Commit

Permalink
add support to change api prefix
Browse files Browse the repository at this point in the history
(from the /api default)
  • Loading branch information
ghedamat committed Feb 5, 2014
1 parent 075a2ec commit 4093b8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"namespace": "appkit",
"APIMethod": "stub",
"proxyURL": "http://localhost:8000",
"proxyPath": "/api",
"version": "0.0.0",
"private": true,
"directories": {
Expand Down
7 changes: 4 additions & 3 deletions tasks/express-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ module.exports = function(grunt) {
app.use(express.urlencoded());
require('../api-stub/routes')(app);
} else if (proxyMethod === 'proxy') {
var proxyURL = grunt.config('express-server.options.proxyURL');
grunt.log.writeln('Proxying API requests to: ' + proxyURL);
var proxyURL = grunt.config('express-server.options.proxyURL'),
proxyPath = grunt.config('express-server.options.proxyPath') || '/api';
grunt.log.writeln('Proxying API requests matching ' + proxyPath + '/* to: ' + proxyURL);

// Use API proxy
app.all('/api/*', passThrough(proxyURL));
app.all(proxyPath + '/*', passThrough(proxyURL));
}

if (target === 'debug') {
Expand Down
5 changes: 3 additions & 2 deletions tasks/options/express-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var grunt = require('grunt');
module.exports = {
options: {
APIMethod: "<%= package.APIMethod %>", // stub or proxy
proxyURL: "<%= package.proxyURL %>" // URL to the API server, if using APIMethod: 'proxy'
proxyURL: "<%= package.proxyURL %>", // URL to the API server, if using APIMethod: 'proxy'
proxyPath: "<%= package.proxyPath %>" // path for the API endpoints, default is '/api', if using APIMethod: 'proxy'
}
};
};

0 comments on commit 4093b8c

Please sign in to comment.