diff --git a/controller/index.js b/controller/index.js index 5d5d854..29e9c55 100644 --- a/controller/index.js +++ b/controller/index.js @@ -235,18 +235,25 @@ var Controller = function( Github, BaseController ){ } req.params.name = req.params.file; Github.tileGet( req.params, data[layer], function( err, tile ){ + if ( err ){ + return res.status(err.code || 500).send( err.message || 'Unknown error while creating the tile' ); + } + if (req.params.format == 'pbf') { res.setHeader('content-encoding', 'deflate'); } if ( req.params.format == 'png' || req.params.format == 'pbf'){ res.sendFile( tile ); - } else { + } + else { if ( callback ){ res.send( callback + '(' + JSON.stringify( tile ) + ')' ); - } else { + } + else { if (typeof tile == 'string'){ res.sendFile( tile ); - } else { + } + else { res.json( tile ); } } diff --git a/package.json b/package.json index c69bbf4..c2fbfbb 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "koop-github", - "version": "0.1.11", + "version": "0.1.12", "description": "A github wrapper for koop ", "main": "index.js", "directories": { "test": "test" }, "scripts": { - "test": "mocha test/" + "test": "mocha test/ -t 20000" }, "dependencies": { "geohub": "0.3.2", diff --git a/test/model-test.js b/test/model-test.js index 10f5065..4b54867 100644 --- a/test/model-test.js +++ b/test/model-test.js @@ -1,6 +1,6 @@ var should = require('should'), config = require('config'), - koop = require('koop-server/lib'); + koop = require('koop/lib'); var repo = 'geodata', user = 'chelm', @@ -9,7 +9,7 @@ var repo = 'geodata', before(function(done){ // setup koop - koop.Cache.db = koop.PostGIS.connect( config.db.postgis.conn ); + koop.Cache.db = koop.LocalDB; var data_dir = __dirname + '/output/'; koop.Cache.data_dir = data_dir; Github = new require('../models/Github.js')( koop ); diff --git a/test/routes-test.js b/test/routes-test.js index be7d172..17f9289 100644 --- a/test/routes-test.js +++ b/test/routes-test.js @@ -1,13 +1,13 @@ var should = require('should'), request = require('supertest'), config = require('config'), - koop = require('koop-server')(config), - kooplib = require('koop-server/lib'); + koop = require('koop')(config), + kooplib = require('koop/lib'); before(function(done){ var provider = require('../index.js'); - model = new provider.model( kooplib ); - controller = new provider.controller( model ); + var model = new provider.model( kooplib ); + var controller = new provider.controller( model, kooplib.BaseController ); koop._bindRoutes( provider.routes, controller ); done(); }); @@ -62,7 +62,7 @@ describe('Koop Routes', function(){ describe('/github/colemanm/hurricanes/fl_2004_hurricanes/FeatureServer', function() { it('should return 200', function(done) { request(koop) - .get('/github/colemanm/hurricanes/fl_2004_hurricanes/FeatureServer') + .get('/github/chelm/geodata/us-states/FeatureServer') .end(function(err, res){ res.should.have.status(200); done();