Routes stuff for FB

This commit is contained in:
Fergal Moran
2016-02-08 23:00:07 +00:00
parent 045ca5d80a
commit 3feada6a0d
3 changed files with 96 additions and 91 deletions

View File

@@ -1,8 +1,9 @@
FROM fergalmoran/node
FROM digitallyseamless/nodejs-bower-grunt-runtime
#FROM fergalmoran/node
ENV NODE_ENV production
#ENV NODE_ENV production
WORKDIR /app/dist/
ADD dist /app/dist/
ENV NODE_ENV production
CMD ["npm", "start"]
#WORKDIR /app/dist/
#ADD dist /app/dist/
#ENV NODE_ENV production
#CMD ["npm", "start"]

View File

@@ -1,84 +1,85 @@
{
"name": "dssweb",
"version": "3.4.2",
"main": "server/app.js",
"dependencies": {
"body-parser": "~1.5.0",
"collections": "^1.2.3",
"composable-middleware": "^0.3.0",
"compression": "~1.0.1",
"connect-mongo": "^0.4.1",
"cookie": "^0.1.3",
"cookie-parser": "~1.0.1",
"cookie-session": "^1.2.0",
"errorhandler": "~1.0.0",
"express": "~4.0.0",
"express-session": "~1.0.2",
"grunt-injector": "^0.6.0",
"grunt-up": "^1.0.7",
"jade": "~1.2.0",
"jit-grunt": "^0.9.1",
"lodash": "~3.10.1",
"method-override": "~1.0.0",
"morgan": "~1.0.0",
"mustache": "^2.1.2",
"redis": "^0.12.1",
"serve-favicon": "~2.0.1",
"socket.io": "^1.0.6",
"socket.io-client": "^1.0.6",
"socketio-jwt": "^3.0.0"
},
"devDependencies": {
"connect-livereload": "~0.4.0",
"grunt": "~0.4.4",
"grunt-angular-templates": "^0.5.4",
"grunt-asset-injector": "^0.1.0",
"grunt-autoprefixer": "~0.7.2",
"grunt-build-control": "DaftMonk/grunt-build-control",
"grunt-concurrent": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-htmlmin": "~0.2.0",
"grunt-contrib-imagemin": "~0.7.1",
"grunt-contrib-jade": "^0.11.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "^0.11.0",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-dom-munger": "^3.4.0",
"grunt-env": "~0.4.1",
"grunt-express-server": "~0.4.17",
"grunt-google-cdn": "~0.4.0",
"grunt-karma": "~0.8.2",
"grunt-mocha-test": "~0.10.2",
"grunt-newer": "~0.7.0",
"grunt-ng-annotate": "^0.2.3",
"grunt-node-inspector": "*",
"grunt-nodemon": "~0.2.0",
"grunt-open": "~0.2.3",
"grunt-protractor-runner": "^1.1.0",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.4.0",
"grunt-usemin": "~2.1.1",
"grunt-wiredep": "~1.8.0",
"jit-grunt": "^0.5.0",
"jshint-stylish": "~0.1.5",
"mustache-express": "^1.2.1",
"open": "~0.0.4",
"requirejs": "~2.1.11",
"should": "~3.3.1",
"supertest": "~0.11.0",
"time-grunt": "~0.3.1"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"start": "node server/app.js",
"test": "grunt test",
"update-webdriver": "node node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update"
},
"private": true
"name": "dssweb",
"version": "3.4.2",
"main": "server/app.js",
"dependencies": {
"body-parser": "~1.5.0",
"collections": "^1.2.3",
"composable-middleware": "^0.3.0",
"compression": "~1.0.1",
"connect-mongo": "^0.4.1",
"cookie": "^0.1.3",
"cookie-parser": "~1.0.1",
"cookie-session": "^1.2.0",
"errorhandler": "~1.0.0",
"express": "~4.0.0",
"express-session": "~1.0.2",
"grunt-injector": "^0.6.0",
"grunt-up": "^1.0.7",
"jade": "~1.2.0",
"jit-grunt": "^0.9.1",
"lodash": "~3.10.1",
"method-override": "~1.0.0",
"morgan": "~1.0.0",
"mustache": "^2.1.2",
"redis": "^0.12.1",
"serve-favicon": "~2.0.1",
"socket.io": "^1.0.6",
"socket.io-client": "^1.0.6",
"socketio-jwt": "^3.0.0",
"ssl-root-cas": "^1.1.10"
},
"devDependencies": {
"connect-livereload": "~0.4.0",
"grunt": "~0.4.4",
"grunt-angular-templates": "^0.5.4",
"grunt-asset-injector": "^0.1.0",
"grunt-autoprefixer": "~0.7.2",
"grunt-build-control": "DaftMonk/grunt-build-control",
"grunt-concurrent": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-htmlmin": "~0.2.0",
"grunt-contrib-imagemin": "~0.7.1",
"grunt-contrib-jade": "^0.11.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "^0.11.0",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-dom-munger": "^3.4.0",
"grunt-env": "~0.4.1",
"grunt-express-server": "~0.4.17",
"grunt-google-cdn": "~0.4.0",
"grunt-karma": "~0.8.2",
"grunt-mocha-test": "~0.10.2",
"grunt-newer": "~0.7.0",
"grunt-ng-annotate": "^0.2.3",
"grunt-node-inspector": "*",
"grunt-nodemon": "~0.2.0",
"grunt-open": "~0.2.3",
"grunt-protractor-runner": "^1.1.0",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.4.0",
"grunt-usemin": "~2.1.1",
"grunt-wiredep": "~1.8.0",
"jit-grunt": "^0.5.0",
"jshint-stylish": "~0.1.5",
"mustache-express": "^1.2.1",
"open": "~0.0.4",
"requirejs": "~2.1.11",
"should": "~3.3.1",
"supertest": "~0.11.0",
"time-grunt": "~0.3.1"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"start": "node server/app.js",
"test": "grunt test",
"update-webdriver": "node node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update"
},
"private": true
}

View File

@@ -1,7 +1,10 @@
'use strict';
var errors = require('./components/errors');
var http = require('http');
var https = require('https');
var url = require('url');
require('ssl-root-cas').inject();
function _parseUrl(u) {
var parts = url.parse(u, true, true);
@@ -41,9 +44,9 @@ module.exports = function (app) {
if (req.headers['user-agent'].indexOf('facebookexternalhit') > -1) {
var url = _parseUrl((app.get('apiUrl') + req.path + '/').replace(/([^:]\/)\/+/g, "$1"));
console.log('Api url: ' + url);
var fun = isHttps(url) ? https : http;
console.log("Using protocol: " + isHttps(url) ? "https" : "http");
fun.get(url, function (api_res) {
//var fun = isHttps(url) ? https : http;
//console.log("Using protocol: ", isHttps(url) ? "https" : "http");
https.get(url, function (api_res) {
var body = '';
api_res.on('data', function (chunk) {
body += chunk;