Skip to content

kristianmandrup/gitlab

 
 

Repository files navigation

gitlab

NPM version build status Test coverage Gittip David deps node version npm download

Gitlab API Node.js client

Install

$ npm install node-gitlab --save

Usage

var gitlab = require('node-gitlab');

var client = gitlab.create({
  api: 'https://gitlab.com/api/v3',
  privateToken: 'your private token'
});

client.milestones.list({id: 1}, function (err, milestones) {
  console.log(err, milestones);
});

Thunk way

Require co and node >= 0.11.12:

var co = require('co');
var gitlab = require('node-gitlab');

var client = gitlab.createThunk({
  api: 'https://gitlab.com/api/v3',
  privateToken: 'your private token'
});

co(function* () {
  var milestones = yield client.milestones.list({id: 1});
})();

Promise way

Require node >= 0.11.13 or bluebird:

var gitlab = require('node-gitlab');

var client = gitlab.createPromise({
  api: 'https://gitlab.com/api/v3',
  privateToken: 'your private token'
});

client.milestones.list({id: 1})
  .then(function (milestones) {
    console.log(milestones);
  })
  .catch(function (err) {
    throw err;
  });

Document

@see Gitlab API document.

Client configuration

Most importantly:

  • API version can be set to v3 or v4
  • privateToken can be found on your gitlab account page
  • requestTimeout should be set between 30-60 secs, depending on size/complexity of API calls (such as a huge commit) or server load etc.
module.exports = {
  api: process.env.NODE_GITLAB_API || 'https://gitlab.com/api/v3',
  privateToken: process.env.NODE_GITLAB_TOKEN || 'enEWf516mA168tP6BiVe',
  requestTimeout: 30000,
};

Alternative Gitlab clients

Project ID

See namespaced-path-encoding

Promise support

All API methods must be added to properties.json to be added to promise client (ie. client.promise)

API docs

Please see the docs folder

Group APIs

See docs/group folder

User APIs

See docs/user folder

Project APIs

See docs/project folder

Repository APIs

See docs/repository folder

More APIs

See Gitlab Full API

TODO

License

(The MIT License)

Copyright (c) 2017 Tecla5 Copyright (c) 2015 repo-utils Copyright (c) 2013 - 2014 fengmk2 fengmk2@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Gitlab nodejs API Client

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%