This repository has been archived by the owner on May 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add semantic releases and IAM support
- Loading branch information
1 parent
72bd98b
commit d3b0154
Showing
21 changed files
with
9,521 additions
and
4,138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Environment variables | ||
VISUAL_RECOGNITION_API_KEY= | ||
VISUAL_RECOGNITION_IAM_APIKEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
language: node_js | ||
dist: trusty | ||
sudo: required | ||
node_js: 6 | ||
node_js: 8 | ||
script: npm test | ||
cache: | ||
directories: | ||
- node_modules | ||
env: | ||
global: | ||
- BX_APP=visual-recognition-demo | ||
- BX_API=https://api.ng.bluemix.net | ||
- BX_ORGANIZATION=WatsonPlatformServices | ||
- BX_SPACE=demos | ||
- VISUAL_RECOGNITION_API_KEY="bogus key to let server spin up for offline tests" | ||
before_install: | ||
- openssl aes-256-cbc -K $encrypted_cca766a893ae_key -iv $encrypted_cca766a893ae_iv | ||
-in .env.enc -out .env -d | ||
deploy: | ||
- provider: script | ||
skip_cleanup: true | ||
script: npx semantic-release | ||
on: | ||
node: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,64 @@ | ||
# Questions | ||
|
||
If you are having difficulties running the app or have a question about the service, please ask a question on [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson) or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson). | ||
If you are having problems using the APIs or have a question about the IBM | ||
Watson Services, please ask a question on | ||
[dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson) | ||
or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson). | ||
|
||
# Code | ||
|
||
* Our style guide is based on [Google's](https://google.github.io/styleguide/jsguide.html), most of it is automaticaly enforced (and can be automatically applied with `npm run autofix`) | ||
* Commits should follow the [Angular commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines). This is because our release tool uses this format for determining release versions and generating changelogs. To make this easier, we recommend using the [Commitizen CLI](https://github.com/commitizen/cz-cli) with the `cz-conventional-changelog` adapter. | ||
|
||
# Issues | ||
|
||
If you encounter an issue with this sample app, you are welcome to submit a [bug report](https://github.com/watson-developer-cloud/visual-recognition-nodejs/issues). Before that, please search for similar issues. It's possible somebody has encountered this issue already. | ||
If you encounter an issue with the Node.js library, you are welcome to submit | ||
a [bug report](https://github.com/watson-developer-cloud/visual-recognition-nodejs/issues). | ||
Before that, please search for similar issues. It's possible somebody has | ||
already encountered this issue. | ||
|
||
# Pull Requests | ||
|
||
If you want to contribute to the repository, here's a quick guide: | ||
If you want to contribute to the repository, follow these steps: | ||
|
||
1. Fork the repo. | ||
1. develop your code changes: `npm install -d` | ||
1. Commit your changes | ||
1. Push to your fork and submit a pull request | ||
2. Develop and test your code changes: `npm install -d && npm test`. | ||
3. Travis-CI will run the tests for all services once your changes are merged. | ||
4. Add a test for your changes. Only refactoring and documentation changes require no new tests. | ||
5. Make the test pass. | ||
6. Commit your changes. | ||
7. Push to your fork and submit a pull request. | ||
|
||
# Developer's Certificate of Origin 1.1 | ||
|
||
By making a contribution to this project, I certify that: | ||
|
||
(a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
|
||
(b) The contribution is based upon previous work that, to the best | ||
of my knowledge, is covered under an appropriate open source | ||
license and I have the right under that license to submit that | ||
work with modifications, whether created in whole or in part | ||
by me, under the same open source license (unless I am | ||
permitted to submit under a different license), as indicated | ||
in the file; or | ||
|
||
(c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
|
||
(d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including all | ||
personal information I submit with it, including my sign-off) is | ||
maintained indefinitely and may be redistributed consistent with | ||
this project or the open source license(s) involved. | ||
|
||
## Tests | ||
|
||
Ideally, we'd like to see both unit and innervation tests on each method. | ||
(Unit tests do not actually connect to the Watson service, integration tests do.) | ||
|
||
Out of the box, `npm test` runs linting and unit tests, but skips the integration tests, | ||
because they require credentials. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,23 +22,19 @@ var fs = require('fs'); | |
var extend = require('extend'); | ||
var path = require('path'); | ||
var async = require('async'); | ||
var watson = require('watson-developer-cloud'); | ||
var VisualRecognitionV3 = require('watson-developer-cloud/visual-recognition/v3'); // watson sdk | ||
var uuid = require('uuid'); | ||
var bundleUtils = require('./config/bundle-utils'); | ||
var os = require('os'); | ||
|
||
var ONE_HOUR = 3600000; | ||
var TWENTY_SECONDS = 20000; | ||
var FOURTY_SECONDS = 40000; | ||
|
||
// Bootstrap application settings | ||
require('./config/express')(app); | ||
|
||
// Create the service wrapper | ||
// If no API Key is provided here, the [email protected] library will check for an VISUAL_RECOGNITION_API_KEY | ||
// environment property and then fall back to the VCAP_SERVICES property provided by the IBM Cloud. | ||
var visualRecognition = new watson.VisualRecognitionV3({ | ||
// api_key: '<api-key>', | ||
version_date: '2015-05-19' | ||
var visualRecognition = new VisualRecognitionV3({ | ||
version: '2018-03-19' | ||
}); | ||
|
||
app.get('/', function(req, res) { | ||
|
@@ -233,8 +229,7 @@ function parseBase64Image(imageString) { | |
app.post('/api/classify', app.upload.single('images_file'), function(req, res) { | ||
var params = { | ||
url: null, | ||
images_file: null, | ||
owners: [] | ||
images_file: null | ||
}; | ||
|
||
if (req.file) { // file image | ||
|
@@ -267,14 +262,13 @@ app.post('/api/classify', app.upload.single('images_file'), function(req, res) { | |
params.threshold = 0.5; //So the classifers only show images with a confindence level of 0.5 or higher | ||
methods.push('classify'); | ||
methods.push('detectFaces'); | ||
methods.push('recognizeText'); | ||
} | ||
|
||
// run the 3 classifiers asynchronously and combine the results | ||
async.parallel(methods.map(function(method) { | ||
var fn = visualRecognition[method].bind(visualRecognition, params); | ||
if (method === 'recognizeText' || method === 'detectFaces') { | ||
return async.reflect(async.timeout(fn, TWENTY_SECONDS)); | ||
if (method === 'detectFaces') { | ||
return async.reflect(async.timeout(fn, FOURTY_SECONDS)); | ||
} else { | ||
return async.reflect(fn); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.