Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
crocodoc-node
Advanced tools
Node.js client library for Crocodoc API v2
This software is released under the MIT license. See LICENSE.md
for more details.
Release Notes, Issues & Roadmap: RELEASE_NOTES.md
From the command-line:
$ npm install crocodoc-node
package.json:
...
dependencies: {
...
"crocodoc-node": "*$version*",
...
}
...
See Contributing section below
The examples below are not intended to replace a working knowledge of the Crocodoc API, nor do they cover all possible uses and responses of the crocodoc-node client library.
They cover the main uses, assuming no errors.
More detailed descriptions of the client library behaviours, including errors, can be found in test-results\*.txt
.
These files were generated from the mocha test suite with the spec reporter.
var documentApi = new require('crocodoc-node').CrocodocAPI('API_TOKEN').documentAPI;
documentApi.uploadFile(pathToSupportedFile, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string: ', body.uuid);
});
documentApi.uploadUrl('http://web.crocodoc.com/files/test-simple.pdf', function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string: ', body.uuid);
});
For a single document:
documentApi.status(docUuid, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body should be an array containing a single status', body);
});
OR for multiple documents:
documentApi.status([docUuid1, docUuid2, ...] , function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body should be an array containing a single status', body);
});
documentApi.remove(docUuid, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body should be true', body);
});
This is additional to the Crocodoc API, and is provided as a helper.
documentApi.poll(docUuid, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body should be a single status', body);
});
The callback will not be invoked until the document has finished converting (or the conversion has failed). The body contains the retrieved document status indicating conversion completion or failure.
var sessionApi = new require('crocodoc-node').CrocodocAPI('API_TOKEN').sessionAPI;
With supplied session options:
sessionApi.create(docUuid, {editable:false, downloadable: true}, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.session should be a non-empty string', body.session);
});
With default session options:
sessionApi.create(docUuid, function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.session should be a non-empty string', body.session);
});
var fs = require('fs');
var downloadApi = new require('crocodoc-node').CrocodocAPI('API_TOKEN').downloadAPI;
downloadApi.document(docUuid, fs.createWriteStream('filePath.orig'), function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string', body.uuid);
});
downloadApi.document(docUuid, {pdf: true}, fs.createWriteStream('filePath.pdf'), function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string', body.uuid);
});
downloadApi.thumbnail(docUuid, '150x150', fs.createWriteStream('filePath.png'), function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string', body.uuid);
});
downloadApi.text(docUuid, fs.createWriteStream('filePath.txt'), function(error, response, body) {
console.log('error should be falsey: ', error);
console.log('response.statusCode should be 200: ', response.statusCode);
console.log('body.uuid should be a non-empty string', body.uuid);
});
https://github.com/NetDevLtd/crocodoc-node/issues
Fork from: https://github.com/NetDevLtd/crocodoc-node
All contributions and constructive suggestions are welcome.
Once you've cloned your fork to a local repo, to install all the dependencies, run:
$ make install
You can then run make lint
and make test
, to de-lint and run the tests, respectively.
In order to run the tests, you will need to configure the test framework with your Crocodoc API token:
edit test/framework/crocodoc-details.js
, and change DUMMY-TOKEN
to your API token.
If you don't do this, many of the tests will fail!
To make git stop tracking changes to this file, so that your sensitive API token doesn't get accidentally committed:
$ git update-index --assume-unchanged test/framework/crocodoc-details.js
You can still explicitly git add
it, or if you want to turn tracking on again:
$ git update-index --no-assume-unchanged test/framework/crocodoc-details.js
These instructions are duplicated in the file.
Please ensure that Pull Requests:
make lint
, with an unmodified jshint.json
test/spec
make test
reports no errors.FAQs
Crocodoc API, node.js client library
We found that crocodoc-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.