Skip to content

Improved error handling and added cover image functionality#1

Merged
SarahZum merged 3 commits intomasterfrom
node-updates
Jul 27, 2017
Merged

Improved error handling and added cover image functionality#1
SarahZum merged 3 commits intomasterfrom
node-updates

Conversation

@SarahZum
Copy link
Copy Markdown
Owner

No description provided.

SarahZum added 3 commits July 27, 2017 14:10
Refinements to error handling
Additional controls for display of browse links and added cover images
@SarahZum SarahZum merged commit ef5d3b7 into master Jul 27, 2017
Copy link
Copy Markdown
Contributor

@karlbecker karlbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall!

One question: have you considered writing any kind of automated acceptance tests, even if they're just against the node app?

If you'd like some guidance, I could try doing it - although I would introduce npm into the repo then, probably using mocha to make a little basic automated test.

Just a thought!

@@ -13,19 +13,33 @@ exports.ArticleLookup = function (event, context, callback) {
var stoID = process.env['stoID'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good job keeping the secrets out of the repo 😊

Comment thread js/browzine.js
$scope.article = response.data;
}, function(error){
console.log(error); //
if (vm.parentCtrl.result.pnx.addata.doi && vm.parentCtrl.result.pnx.display.type[0] == 'article') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little formatting nit here, but the (probably unintentional?) whitespace changes here can tend to mess up diffs and make reviews a little longer to get through.

I thought I'd mention something that's been useful on our team: the .editorconfig file, as described at http://editorconfig.org

You put it in the root directory of your project, and when opening that directory in a text editor, many text editors recognize the preferences there and will respect them, independent of their own preferred settings. It'll help changes like this here - swapping in tabs for spaces - from unintentionally happening.

Hopefully this wasn't too much of a bike shed comment 😊 🚲

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all, great tip--I'll give it a try!

Comment thread js/browzine.js
console.log(error); //
if (vm.parentCtrl.result.pnx.addata.doi && vm.parentCtrl.result.pnx.display.type[0] == 'article') {
vm.doi = vm.parentCtrl.result.pnx.addata.doi[0] || '';
var articleURL = "https://yourserver.edu/primo/browzine/browzineArticleInContext?DOI=" + vm.doi;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the guidance for first-time setup would be to simply change yourserver.edu to wherever we're installing things, correct?

Also, is the js/browzine.js file something that each Primo user must put somewhere into the Primo installation?

I'm sure more full instructions are coming, so I'll stop my questions about setup instructions until I see them 😊

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readme updated! Let me know what could still use clarification??

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sarah! Readme answers those questions now, excellent.

I will try setting something up with Amazon Lambda, because that sounds like a great use for it and would make setup much simpler than setting up a variety of EC2 boxes.

Comment thread js/browzine.js
}
if (vm.parentCtrl.result.pnx.addata.issn && vm.parentCtrl.result.pnx.display.type[0] == 'journal') {
vm.issn = vm.parentCtrl.result.pnx.addata.issn[0].replace("-", "") || '';
var journalURL = "https://yourserver.edu/primo/browzine/browzineJournals?ISSN=" + vm.issn;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since yourserver.edu is sprinkled throughout this file, would it make sense to define it once up at the top, then use string literals throughout the rest of the file, to reduce the likelihood of typos?

Something like:

const serverName = 'yourserver.edu';
...
var journalURL = `https://${serverName}/primo/browzine/browzineJournals?ISSN=${vm.issn}`;

perhaps? Changing yourserver.edu becomes a one-line change instead of a multi-line find and replace in this case.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call--and I actually already did set the constant when whitelisting our server address so I should utilize it!

} else {
// Browzine's API returns a 404 if data isn't found, so send an empty response if call is unsuccessful
callback(null,
cb + '({"data":[]})'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - though if we put in an empty object with our 404, would that be nicer?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would save a little bit on the conditional logic, but I understand your perspective on returning a 404 for a bad DOI (I didn't realize that was what was going on with those queries), so I'm content either way!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - we'll stick with it for now, but I'm making a note for a future potential change.

Comment thread js/browzine.js
if (vm.parentCtrl.result.pnx.addata.doi && vm.parentCtrl.result.pnx.display.type[0] == 'article') {
vm.doi = vm.parentCtrl.result.pnx.addata.doi[0] || '';
var articleURL = "https://yourserver.edu/primo/browzine/browzineArticleInContext?DOI=" + vm.doi;
$http.jsonp(articleURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used jsonp before, though I've ready about it - will need to read a little bit to remind myself precisely how it works! Seems to make sense here though: a string is returned back from the node server to here, and the jsonp function decodes it and builds json from the response payload, correct?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly--to get around all the domain-crossing going on :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants