Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
APF-1357 Addresses review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
shsmysore committed Aug 26, 2018
1 parent 3b58300 commit c1edb95
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 41 deletions.
7 changes: 4 additions & 3 deletions samples/node/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ app.use(['/cards/requests', '/reports'], function (req, res, next) {
if (authorization) {
console.log(`Client passed "${authorization}". We should authenticate using a public key from VMware Identity Manager`);
} else {
res.status(401).send("Missing Authorization header");
return
return res.status(401).send("Missing Authorization header");
}
if (xAuthorization) {
console.log(`Client passed "${xAuthorization}". Connector will use this to fetch info. form the backend Weather system.`);
next();
} else {
res.status(400).send("Missing X-Connector-Authorization header");
const r = res.status(400);
r.setHeader('X-Backend-Status', 401);
r.send("Missing X-Connector-Authorization header");
}
});

Expand Down
25 changes: 0 additions & 25 deletions samples/node/discovery/metadata.json

This file was deleted.

9 changes: 4 additions & 5 deletions samples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"start": "node connector.js"
},
"dependencies": {
"express" : "4.15.x",
"body-parser" : "1.17.x",
"command-line-args" : "4.0.x",
"uuid" : "3.0.x",
"halberd": "0.2.x"
"express": "4.15.x",
"body-parser": "1.17.x",
"command-line-args": "4.0.x",
"uuid": "3.0.x"
}
}
24 changes: 16 additions & 8 deletions samples/node/routes/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@

"use strict";

const fs = require('fs');

exports.root = function (req, res) {
const base = `${protocol(req)}://${host(req)}`;
fs.readFile('./discovery/metadata.json', 'utf8', function (err, contents) {
res.setHeader('Content-Type', 'application/json');
res.send(
contents.replace(new RegExp('@@_CONNECTOR_HOST_@@', 'g'), base)
);
});
const body = {
image: {href: `${base}/images/connector.png`},
test_auth: {href: `${base}/test-auth`},
object_types: [
{
name: "card",
doc: {href: "https://github.com/vmwaresamples/card-connectors-guide/wiki/Card-Responses"},
fields: {
zip: {capture_group: 1, regex: "([0-9]{5})(?:[- ][0-9]{4})?"}
},
endpoint: {href: `${base}/cards/requests`}
}
]
};
res.setHeader('Content-Type', 'application/json');
res.send(body);
};

function protocol(req) {
Expand Down

0 comments on commit c1edb95

Please sign in to comment.