forked from CartoDB/Windshaft
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove defaults from test serveropts and refactor
- Loading branch information
Showing
2 changed files
with
53 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,21 @@ | ||
var _ = require('underscore'); | ||
|
||
module.exports = function(opts) { | ||
module.exports = function() { | ||
|
||
var config = { | ||
var testDefaults = { | ||
dbtype: global.environment.dbtype, | ||
tileRoute: '/database/:dbname/table/:table/:z/:x/:y.*', | ||
grainstore: {datasource: global.environment.datasource}, | ||
enableCors: false, | ||
logRequests: true, | ||
logErrors: true, | ||
logErrorTrace: true, | ||
showErrors: true, | ||
parameterParser: function(req, callback){ | ||
|
||
// no default interactivity. to enable specify the database column you'd like to interact with | ||
req.params.interactivity = null; | ||
req.params.sql = "SELECT * FROM " + req.params.table; | ||
|
||
req.params.sql = "SELECT * FROM "+req.params.table; | ||
|
||
// this is in case you want to test sql parameters eg ...png?sql=select * from my_table limit 10 | ||
req.params = _.extend({}, req.params); | ||
_.extend(req.params, req.query); | ||
|
||
|
||
// send the finished req object on | ||
callback(null,req); | ||
}, | ||
beforeTileRender: function(req, res, callback) { | ||
res.header('X-BeforeTileRender', 'called'); | ||
callback(null); | ||
}, | ||
afterTileRender: function(req, res, tile, headers, callback) { | ||
res.header('X-AfterTileRender','called'); | ||
headers['X-AfterTileRender2'] = 'called'; | ||
callback(null, tile, headers); | ||
} | ||
|
||
} | ||
|
||
_.extend(config, opts || {}); | ||
|
||
return config; | ||
|
||
return testDefaults; | ||
}(); |