diff --git a/server/maps.js b/server/maps.js index 60373b7..63773c5 100644 --- a/server/maps.js +++ b/server/maps.js @@ -182,9 +182,8 @@ var mapmodule = function(db, share) { res.statusCode = 500; res.send(JSON.stringify(err)); } else { - res.writeHead(200, { - 'content-type' : 'text/html' - }); + res.setHeader('Content-Type', 'application/json'); + res.send(JSON.stringify({})); res.end(); } }); @@ -237,9 +236,8 @@ var mapmodule = function(db, share) { res.statusCode = 500; res.send(JSON.stringify(err)); } else { - res.writeHead(200, { - 'content-type' : 'text/html' - }); + res.setHeader('Content-Type', 'application/json'); + res.send(JSON.stringify({})); res.end(); } }); @@ -278,7 +276,7 @@ var mapmodule = function(db, share) { if (!maps[0].anonymousShare) { maps[0].anonymousShare = false; } else { - maps[0].anonymousShareLink = share.constructSharingURL(req, mapId); + maps[0].anonymousShareLink = share[0].constructSharingURL(req, mapId); } if(!maps[0].preciseShare){ maps[0].preciseShare = []; diff --git a/server/server.js b/server/server.js index ff09ebd..0074cdc 100755 --- a/server/server.js +++ b/server/server.js @@ -89,13 +89,15 @@ var WardleyMapsApp = function(configOptions) { var userProvider = require('./user-provider')(app); - self.db = require('./db')(configOptions.databaseConnectionString); + var share = [null]; + + self.db = require('./db')(configOptions.databaseConnectionString); self.exportmap = new require('./export')(self.db); - self.maps = new require('./maps')(self.db, self.share); + self.maps = new require('./maps')(self.db, share); - var share = require('./router/share.js')('/share', self.db, userProvider.loginRequired, self.maps, self.exportmap); + share[0] = require('./router/share.js')('/share', self.db, userProvider.loginRequired, self.maps, self.exportmap); - app.use('/share', share.router); + app.use('/share', share[0].router); app.use('/profile', userProvider.loginRequired, require('./router/profilerouter.js')().router); app.use('/api', userProvider.authenticationRequired, require('./router/apirouter.js')(self.maps, self.exportmap).router); app.use('/', userProvider.loginRequired, require('./router/mainrouter.js')(self.maps).router);