0.4.0 • Published 4 years ago
temporarlt-created-package v0.4.0
Redmine-ts
redmine-ts is Redmine REST API client written using TypeScript and using Axios for making requests.. It supports 100% of Redmine's API features.
Limitations:
- The current version only supports JSON format (implementation of XML versions is not planned)
apiKey
is the only authentication method right now
Known problems:
- The parameter
cf_x
in thelistIssues
method (API ref) was not included, so TypeScript reports an error. Currently, to work around this problem, please use@ts-ignore
Search
method - Since official documentation are not completed yet, onlylimit
andoffset
parameters are available.
Installation
npm install --save redmine-ts
Usage
const fs = require('fs');
import {Redmine} from 'redmine-ts';
// Initialization (with all available parameters)
const redmine = new Redmine('https://redmine-hostname.com:3000', {
/**
* apiKey (required) Redmine API key
*/
apiKey: 'abcdef0123456789abcdef0123456789',
/**
* maxUploadSize (optional) Maximum size of sent files in bytes. Default value: 5242880 (5MB)
* Note that it's only changes the maxBodyLength parameter of axios.
* Max upload size accepted by Redmine needs to be setted by administrator in settings!
*/
maxUploadSize: 5242880
});
// Example 1: List 5 issues
redmine.listIssues({
limit: 5
})
.then(iObj => {
console.log(`Showing ${iObj.issues.length} of ${iObj.total_count} total results:`, iObj.issues)
})
.catch(err) {
console.log('List issues error:', err)
}
// Example 2: Add attachment to issue
const fileContent = fs.readFileSync('example-image.png');
redmine.uploadFile(fileContent).then(res => {
const { token } = res.upload;
redmine.updateIssue(1, {
uploads: [
token,
filename: 'sweet-duckling.png',
content_type: 'image/png',
description: 'A photo of a yellow lovely duckling!'
]
})
})
Planned improvements
- Add support for username/password authentication
- Add support for User-Impersonation
License
This software is distributed under the MIT License.