@cocreate/cocreatews
Advanced tools
Comparing version 0.6.16 to 0.6.17
@@ -0,1 +1,8 @@ | ||
## [0.6.17](https://github.com/CoCreate-app/CoCreateWS/compare/v0.6.16...v0.6.17) (2021-04-10) | ||
### Bug Fixes | ||
* Cleaned file structure ([20b227d](https://github.com/CoCreate-app/CoCreateWS/commit/20b227d291476cc32c43172e4d4979b129ea7914)) | ||
## [0.6.16](https://github.com/CoCreate-app/CoCreateWS/compare/v0.6.15...v0.6.16) (2021-04-09) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@cocreate/cocreatews", | ||
"version": "0.6.16", | ||
"version": "0.6.17", | ||
"description": "CoCreateWS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,5 +11,7 @@ var utils = require("../helpers/utils.js"); | ||
let route_uri = url.split(req.hostname)[0]; | ||
let masterDB = '5ae0cfac6fb8c4e656fdaf92' | ||
route_uri = route_uri.indexOf('?') ? route_uri.split('?')[0] : route_uri | ||
let organization = await utils.organizationsfindOne({domains:hostname},'5de0387b12e200ea63204d6c') | ||
let organization = await utils.organizationsfindOne({domains:hostname},masterDB) | ||
@@ -33,6 +35,4 @@ if(organization == null) { | ||
let content_type = ''; | ||
let is_file = route['is_file']; | ||
let ext = path.extname(route_uri); | ||
if (!is_file) { | ||
@@ -48,4 +48,3 @@ switch(ext){ | ||
content_type = 'text/xml' | ||
break; | ||
content_type = 'text/html' | ||
break; | ||
default: | ||
@@ -64,7 +63,7 @@ content_type = 'text/html' | ||
else { | ||
res.send('Error Get ROute Document Export Collection -> '+route['collection'] + ' document_id -> '+route['document_id']); | ||
res.send('Document provided by routes could not be found in collection: '+route['collection'] + ' document_id: '+route['document_id']); | ||
} | ||
} | ||
else { | ||
res.send('No Found this ROute in ours BD Host ['+hostname+'] and OrgId ['+organization_id+'] '); | ||
res.send('Organization could not be found for ['+hostname+'] in masterDb ['+organization_id+'] '); | ||
} | ||
@@ -74,54 +73,1 @@ } | ||
} | ||
module.exports.getRoute = async (req, res, next) => { | ||
// to test -> http://52.207.107.241:8081/organization/hello/org | ||
// -> https://server.cocreate.app:8088/organization/test/frank | ||
/* | ||
db.organizations.findOneAndUpdate( | ||
{ _id:ObjectId('5de0387b12e200ea63204d6c') }, | ||
{ $set: { "routes" : [{ | ||
route: '/test/frank', | ||
collection: 'module_activities', | ||
document_id: "5e4802ce3ed96d38e71fc7e5", | ||
name: 'name1', | ||
}, | ||
{ | ||
route: '/hello/jean', | ||
collection: 'modules', | ||
document_id: '5de03fc7c745412976891134', | ||
name: 'html', | ||
}, | ||
{ | ||
route: '/hello/org', | ||
collection: 'organizations', | ||
document_id: '5f03eb8462181154025cd876', | ||
name: 'name', | ||
} | ||
]} }, | ||
{ upsert:true, returnNewDocument : true } | ||
); | ||
*/ | ||
console.log("URL=> ",req.url , " req.hostname ", req.hostname) | ||
let route_uri = req.url.split('/organization')[1]; | ||
let organization_id = '5de0387b12e200ea63204d6c'; | ||
var org = await utils.getDocument({'collection':'organizations','document_id':organization_id}); | ||
var route = org.routes.find(element => element.route.toLowerCase() == route_uri); | ||
if (typeof route != 'undefined'){ | ||
console.log(" Route ",route); | ||
var result = await utils.getDocument(route); | ||
console.log("Result ",result) | ||
res.send(result[route.name]); | ||
} | ||
else { | ||
let list_route = '<ul>' | ||
org.routes.forEach(function(route) { | ||
list_route += '<li>'+route.route+'</li>'; | ||
}); | ||
list_route += '</ul>' | ||
res.send('This route does not exist: '+list_route); | ||
} | ||
} | ||
64842
408