Skip to content

Commit 296cf77

Browse files
committed
SUPPO-1256: Finalize example running instructions. Stray notes for DEVELOPER.md
1 parent e1256e1 commit 296cf77

File tree

2 files changed

+66
-24
lines changed

2 files changed

+66
-24
lines changed

DEVELOPER.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Binding Developer Info
2+
3+
#### Build and Release Instructions
4+
TBD
5+
Include notes on updating Travis test versions, keeping `package.json` fresh.
6+
Maybe some notes on updating dependency versions, linting, dependency vulnerabilities, etc.
7+
There appears to be some mixed whitespace that should be tidied up.
8+
9+
10+
#### Old Docker Info From Examples
11+
If we want to keep this, let's clean it up.
12+
13+
`runAll.sh` is testing a string instead of an http code.
14+
`runAl.sh` and `Dockerfile` may need to be consolidated with the other example scripts.
15+
16+
Here are the old instructions from examples/README.
17+
18+
##### Docker
19+
A Docker image for running the examples against the compiled source library is available on Docker Hub.
20+
21+
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-nodejs`
22+
23+
Additional environment settings:
24+
`-e ALT_URL=<alternative URL>`
25+
`-e FILENAME=<single filename>`
26+
27+
##### Example using the Rosette API language detection endpoint
28+
```javascript
29+
var Api = require('rosette-api');
30+
31+
var api = new Api(API_KEY);
32+
var endpoint = "language";
33+
var content = "Por favor Señorita, says the man.";
34+
api.parameters.content = content;
35+
36+
api.rosette(endpoint, function(err, res){
37+
if(err){
38+
console.log(err);
39+
} else {
40+
console.log(JSON.stringify(res, null, 2));
41+
}
42+
});
43+
```

examples/README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
## Endpoint Examples
2-
32
Each example file demonstrates one of the capabilities of the Rosette Platform.
43

5-
## Docker ##
6-
A Docker image for running the examples against the compiled source library is available on Docker Hub.
7-
8-
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-nodejs`
9-
10-
Additional environment settings:
11-
`-e ALT_URL=<alternative URL>`
12-
`-e FILENAME=<single filename>`
4+
Here are some methods for running the examples. Each example will also accept an optional `--url` parameter for
5+
overriding the default URL.
136

14-
## Example using the Rosette API language detection endpoint
15-
```javascript
16-
var Api = require('rosette-api');
7+
A note on prerequisites. Rosette API only supports TLS 1.2 so ensure your toolchain also supports it.
178

18-
var api = new Api(API_KEY);
19-
var endpoint = "language";
20-
var content = "Por favor Señorita, says the man.";
21-
api.parameters.content = content;
9+
#### Docker/Latest Release
10+
```
11+
git clone [email protected]:rosette-api/nodejs.git
12+
cd nodejs/examples
13+
docker run -it --entrypoint sh -v $(pwd):/examples node:12-alpine
14+
cd /examples
15+
npm install rosette-api argparse
16+
sed -i s',require("../lib/Api"),require("rosette-api"),' ping.js
17+
node ping.js --key $API_KEY
18+
```
2219

23-
api.rosette(endpoint, function(err, res){
24-
if(err){
25-
console.log(err);
26-
} else {
27-
console.log(JSON.stringify(res, null, 2));
28-
}
29-
});
30-
```
20+
#### Docker/Current Source
21+
```
22+
git clone [email protected]:rosette-api/nodejs.git
23+
cd nodejs
24+
docker run -it --entrypoint sh -v $(pwd):/source node:12-alpine
25+
cd /source
26+
npm install
27+
cd examples
28+
node ping.js --key $API_KEY
29+
```

0 commit comments

Comments
 (0)