[CORD-873] removed proxy routes for REST APIs as provided by chameleon
Change-Id: Ic28404521dcd95c8dfa927f1b41b9eeb4ef7c724
diff --git a/spec/core_proxy.spec.js b/spec/core_proxy.spec.js
index 5cd4a70..94ba531 100644
--- a/spec/core_proxy.spec.js
+++ b/spec/core_proxy.spec.js
@@ -20,7 +20,7 @@
let app;
- describe('The core proxy routes', () => {
+ xdescribe('The core proxy routes [REST API moved to chameleon]', () => {
// stub for GET method
stub.makeStub('getSuccess', request, 'get', cb => {
diff --git a/src/routes/core_proxy.js b/src/routes/core_proxy.js
deleted file mode 100644
index 75d2840..0000000
--- a/src/routes/core_proxy.js
+++ /dev/null
@@ -1,68 +0,0 @@
-(function () {
- 'use strict';
-
- const request = require('superagent');
- const logger = require('../config/logger.js');
-
- module.exports = function(app) {
-
- const proxyRequest = (req, res) => {
-
- // debugging helper
- if(!req.headers['x-csrftoken']){
- logger.log('warn', `csrftoken is missing and is required for authentication for ${req.url}`);
- }
- if(!req.headers['x-sessionid']){
- logger.log('warn', `Session id is missing and is required for authentication for ${req.url}`);
- }
-
- const config = require('../config/config.js').xos;
- // pick the correct method from superAgent
- const makeReq = request[req.method.toLowerCase()];
-
- // start the request
- let sentReq = makeReq(`${config.host}:${config.port}${req.url}`);
-
- // if needed add a body to the request
- if(req.method === 'POST' || req.method === 'PUT') {
- sentReq = sentReq
- .send(req.body)
- }
-
- // extend with auth info
- if(req.headers['x-csrftoken'] && req.headers['x-sessionid']){
- sentReq = sentReq
- .set('x-csrftoken', req.headers['x-csrftoken'] || null)
- .set('cookie', `xoscsrftoken=${req.headers['x-csrftoken']}; xossessionid=${req.headers['x-sessionid']}` || null)
- }
-
- // handle response
- sentReq
- .end((err, r) => {
- if(err) {
- logger.log('error', sentReq.method, sentReq.url, err);
- let errRes;
- try {
- errRes = err.response.error;
- }
- catch(e) {
- errRes = err;
- }
- return res.status(err.status).send(errRes);
- }
- logger.log('debug', sentReq.method, sentReq.url, r.status);
- logger.log('silly', r.text)
- return res.status(r.status).type('json').send(r.body);
- });
- };
-
- app.all('/api/core', proxyRequest);
- app.all('/api/core/*', proxyRequest);
- app.all('/api/service', proxyRequest);
- app.all('/api/service/*', proxyRequest);
- app.all('/api/tenant', proxyRequest);
- app.all('/api/tenant/*', proxyRequest);
- app.all('/api/utility', proxyRequest);
- app.all('/api/utility/*', proxyRequest);
- };
-})();
diff --git a/src/server.js b/src/server.js
index c132cab..4524ea1 100644
--- a/src/server.js
+++ b/src/server.js
@@ -14,10 +14,10 @@
app.use(bodyParser.json());
// Load routes
- require('./routes/core_proxy.js')(app);
+ // require('./routes/core_proxy.js')(app);
app.get('/', function(req, res) {
- res.send('Hello world');
+ res.send('Welcome to the websocket server for XOS');
});
const startServer = (port) => {