Skip to content

Commit b8e3980

Browse files
authored
Fixing mocha tests (#76)
* Fixing mocha tests * Remove geo routed location from the options * upgraded runtime to node 20 * Tweaking CI * Tweaking main CI
1 parent 75dfa81 commit b8e3980

File tree

10 files changed

+443
-947
lines changed

10 files changed

+443
-947
lines changed

.github/workflows/master.yaml renamed to .github/workflows/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
on:
22
push:
33
branches:
4-
- master
4+
- main
55
jobs:
66
deploy:
77
if: "!contains(github.event.commits[0].message, '[ci skip]')"
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Use Node.js 12.x
11+
- name: Setup node
1212
uses: actions/setup-node@v1
1313
with:
14-
node-version: 12.x
14+
node-version: 20.x
1515
- name: Configure AWS credentials
1616
uses: aws-actions/configure-aws-credentials@v1
1717
with:

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
node-version: [ 12.x, 14.x ]
9+
node-version: [ 20.x, ]
1010

1111
steps:
1212
- uses: actions/checkout@v2

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package:
1111
npm-install:
1212
npm install .
1313

14-
test: clean npm-install
14+
test:
1515
npm test
1616

1717
clean:

lib/client.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ const axios = require('axios');
44
const querystring = require('querystring')
55

66
/**
7-
* Minimal Scanii API client in javascript (@see https://docs.scanii.com/v2.1/resources.html)
7+
* Minimal Scanii API client in javascript (@see https://docs.scanii.com)
88
*/
99
class ScaniiClient {
10-
constructor(key, secret, endpoint = "api.scanii.com", maxAttempts, maxAttemptDelay) {
10+
constructor(key, secret, endpoint = "api.scanii.com", maxAttempts = 3, maxAttemptDelay = 1000) {
1111
this.key = key;
1212
this.secret = secret;
1313
this.maxAttempts = maxAttempts;
1414
this.maxAttemptDelay = maxAttemptDelay;
1515
this.userAgent = `scanii-lambda/v${VERSION}`;
16+
1617
this.client = axios.create({
1718
auth: {
1819
username: key, password: secret
@@ -26,7 +27,7 @@ class ScaniiClient {
2627
}
2728

2829
/**
29-
* Makes a fetch call to scanii @see <a href="http://docs.scanii.com/v2.1/resources.html#files">http://docs.scanii.com/v2.1/resources.html#files</a>
30+
* Makes a fetch call to scanii, see https://uvasoftware.github.io/openapi/v22/#/Files/processFileFetch
3031
* @param location (URL) of the content to be processed
3132
* @param callback callback location (URL) to be notified and receive the result
3233
* @param metadata optional metadata to be added to this file
@@ -50,7 +51,7 @@ class ScaniiClient {
5051
}
5152

5253
return await this._retry(async () => {
53-
const response = await this.client.post('/v2.1/files/fetch', querystring.stringify(data), {headers: {'content-type': 'application/x-www-form-urlencoded'}});
54+
const response = await this.client.post('/v2.2/files/fetch', querystring.stringify(data), {headers: {'content-type': 'application/x-www-form-urlencoded'}});
5455
assert.ok(response.status === 202, `Invalid response from server, with HTTP code: ${response.status}`);
5556
console.log(`submit successful with id: ${response.data.id}`);
5657
return ({id: response.data.id, location: response.headers.location});
@@ -59,13 +60,13 @@ class ScaniiClient {
5960

6061
// noinspection JSUnusedGlobalSymbols
6162
/**
62-
* Fetches the results of a previously processed file @see <a href="http://docs.scanii.com/v2.1/resources.html#files">http://docs.scanii.com/v2.1/resources.html#files</a>
63+
* Fetches the results of a previously processed file @see https://uvasoftware.github.io/openapi/v22/#/Files/retrieveFile
6364
* @param id of the content/file to be retrieved
6465
* @returns {Promise<*>}
6566
*/
6667
async retrieve(id) {
6768
return await this._retry(async () => {
68-
const response = await this.client.get(`/v2.1/files/fetch/${id}`);
69+
const response = await this.client.get(`/v2.2/files/fetch/${id}`);
6970
assert.ok(response.status === 200, `Invalid response from server, with HTTP code: ${response.status}`);
7071
let result = JSON.parse(response.data);
7172
console.log(`retrieve successful with id: ${result.id}`);

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (process.env.AWS_SAM_LOCAL !== undefined) {
88
function defaults() {
99
CONFIG.KEY = null;
1010
CONFIG.SECRET = null;
11-
CONFIG.API_ENDPOINT = "api.scanii.com";
11+
CONFIG.API_ENDPOINT = "api-us1.scanii.com";
1212
CONFIG.CALLBACK_URL = null;
1313
CONFIG.ACTION_TAG_OBJECT = false;
1414
CONFIG.ACTION_DELETE_OBJECT = false;

0 commit comments

Comments
 (0)