diff --git a/CHANGELOG.md b/CHANGELOG.md index b7fd7b054..97c3e43b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,24 @@ # [7.0.0](https://github.com/jdalrymple/node-gitlab/compare/6.4.0...7.0.0) (2019-06-28) - ### Features -* Adding missing endpoints for deploy keys [#373](https://github.com/jdalrymple/node-gitlab/issues/373) ([b23dd29](https://github.com/jdalrymple/node-gitlab/commit/b23dd29)) - +- Adding missing endpoints for deploy keys [#373](https://github.com/jdalrymple/node-gitlab/issues/373) ([b23dd29](https://github.com/jdalrymple/node-gitlab/commit/b23dd29)) ### BREAKING CHANGES -* all method now takes an optional object since projectId is no longer required. If no projectId is passed, the all method returns all deploy keys across all projects of the GitLab instance +- all method now takes an optional object since projectId is no longer required. If no projectId is passed, the all method returns all deploy keys across all projects of the GitLab instance # [6.4.0](https://github.com/jdalrymple/node-gitlab/compare/6.3.7...6.4.0) (2019-06-28) - ### Bug Fixes -* Handle body types properly if not JSON ie formData ([a135841](https://github.com/jdalrymple/node-gitlab/commit/a135841)), closes [#355](https://github.com/jdalrymple/node-gitlab/issues/355) -* Missing headers when posting json data ([861f89e](https://github.com/jdalrymple/node-gitlab/commit/861f89e)) -* Use the correct agent configuration for the rejectUnauthorized option ([775d755](https://github.com/jdalrymple/node-gitlab/commit/775d755)), closes [#357](https://github.com/jdalrymple/node-gitlab/issues/357) - +- Handle body types properly if not JSON ie formData ([a135841](https://github.com/jdalrymple/node-gitlab/commit/a135841)), closes [#355](https://github.com/jdalrymple/node-gitlab/issues/355) +- Missing headers when posting json data ([861f89e](https://github.com/jdalrymple/node-gitlab/commit/861f89e)) +- Use the correct agent configuration for the rejectUnauthorized option ([775d755](https://github.com/jdalrymple/node-gitlab/commit/775d755)), closes [#357](https://github.com/jdalrymple/node-gitlab/issues/357) ### Features -* Adding support for Group Issues ([00068c9](https://github.com/jdalrymple/node-gitlab/commit/00068c9)), closes [#306](https://github.com/jdalrymple/node-gitlab/issues/306) +- Adding support for Group Issues ([00068c9](https://github.com/jdalrymple/node-gitlab/commit/00068c9)), closes [#306](https://github.com/jdalrymple/node-gitlab/issues/306) ## [6.3.7](https://github.com/jdalrymple/node-gitlab/compare/6.3.6...6.3.7) (2019-06-12) diff --git a/README.md b/README.md index b41308654..146d90eac 100644 --- a/README.md +++ b/README.md @@ -158,23 +158,29 @@ import { Projects } from 'gitlab'; // Just the Project Resource const { Gitlab } = require('gitlab'); ``` -Instatiating options: +Basic Example ```javascript const api = new Gitlab({ - host: 'http://gl.com', //Optional, Default: https://gitlab.com - token: 'personaltoken', //Personal Token. Required (one of the three tokens are required) - oauthToken: 'oauthtoken', //OAuth Token. Required (one of the three tokens are required) - jobToken: 'myJobToken', //CI job token. Required (one of the three tokens are required) - rejectUnauthorized: false //Http Certificate setting. Optional, Default: false - sudo: false //Sudo query parameter. Optional, Default: false - version = 'v4', //API Version ID. Optional, Default: v4 - camelize = false, //Response Key Camelize. Camelizes all response body keys. Optional, Default: false - requester = KyRequester, //Request Library Wrapper. Optional, Default: Currently wraps Ky. - requestTimeout = 300000 //Request Library Timeout. Optional, Default: 300,000 milliseconds. + token: 'personaltoken', }); ``` +Available instatiating options: + +| Name | Optional | Default | Description | +| -------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------- | +| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL | +| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) | +| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) | +| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) | +| `rejectUnauthorized` | Yes | `false` | Http Certificate setting | +| `sudo` | Yes | `false` | Sudo query parameter | +| `version` | Yes | `v4` | API Version ID | +| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys | +| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. | +| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms | + #### Bundle Imports It can be annoying to have to import all the API's pertaining to a specific resource. For example, the Projects resource is composed of many API's, Projects, Issues, Labels, MergeRequests, etc. For convenience, there is a Bundle export for importing and instantiating all these related API's at once. @@ -183,8 +189,8 @@ It can be annoying to have to import all the API's pertaining to a specific reso import { ProjectsBundle } from 'gitlab'; const services = new ProjectsBundle({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456' // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456' }) services.Projects.all() @@ -303,8 +309,8 @@ Using the await/async method import { Gitlab } from 'gitlab'; const api = new Gitlab({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456', // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456', }); // Listing users @@ -327,8 +333,8 @@ ie. import { Gitlab } from 'gitlab'; const api = new Gitlab({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456', // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456', }); api.Projects.create(projectId, { @@ -344,8 +350,8 @@ For any .all() function on a resource, it will return all the items from Gitlab. import { Gitlab } from 'gitlab'; const api = new Gitlab({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456', // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456', }); let projects = await api.Projects.all({ maxPages: 2 }); @@ -357,8 +363,8 @@ You can also use this in conjunction to the perPage argument which would overrid import { Gitlab } from 'gitlab'; const api = new Gitlab({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456', // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456', }); let projects = await api.Projects.all({ maxPages: 2, perPage: 40 }); @@ -405,8 +411,8 @@ For example, if you want to disable notifications for a specific user: import { NotificationSettings } from 'gitlab'; const service = new NotificationSettings({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456' // Can be created in your profile. + host: 'http://example.com', + token: 'abcdefghij123456' sudo: 8 // Can be the user ID or a username }); @@ -428,11 +434,10 @@ import { Gitlab } from 'gitlab'; import YourCustomRequester from 'custom-requester'; const api = new Gitlab({ - host: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456' // Can be created in your profile. - requester: YourCustomRequester + host: 'http://example.com', + token: 'abcdefghij123456', + requester: YourCustomRequester, }); - ``` ## Docs diff --git a/src/infrastructure/KyRequester.ts b/src/infrastructure/KyRequester.ts index 4fbec9fa9..d49c9e42d 100644 --- a/src/infrastructure/KyRequester.ts +++ b/src/infrastructure/KyRequester.ts @@ -4,7 +4,6 @@ import { decamelizeKeys } from 'humps'; import { stringify } from 'query-string'; import { skipAllCaps } from './Utils'; import { Requester } from '.'; -import { Agent } from 'https'; const methods = ['get', 'post', 'put', 'delete', 'stream']; const KyRequester = {} as Requester; @@ -23,7 +22,6 @@ function responseHeadersAsObject(response) { function defaultRequest(service: any, { body, query, sudo, method }) { const headers = new Headers(service.headers); let bod = body; - let agent; if (sudo) headers.append('sudo', `${sudo}`); @@ -32,12 +30,6 @@ function defaultRequest(service: any, { body, query, sudo, method }) { headers.append('content-type', 'application/json'); } - if (service.rejectUnauthorized) { - agent = new Agent({ - rejectUnauthorized: service.rejectUnauthorized, - }); - } - return { timeout: service.requestTimeout, headers, @@ -46,7 +38,6 @@ function defaultRequest(service: any, { body, query, sudo, method }) { searchParams: stringify(decamelizeKeys(query || {}) as any, { arrayFormat: 'bracket' }), prefixUrl: service.url, body: bod, - agent, }; } diff --git a/test/integration/bundles/ProjectsBundle.ts b/test/integration/bundles/ProjectsBundle.ts index 4998ec915..76e0aec3b 100644 --- a/test/integration/bundles/ProjectsBundle.ts +++ b/test/integration/bundles/ProjectsBundle.ts @@ -3,7 +3,6 @@ import { ProjectsBundle } from '../../../src'; const config = { host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }; let project; let api; diff --git a/test/integration/services/ApplicationSettings.ts b/test/integration/services/ApplicationSettings.ts index 0a2f293d4..2977e2e24 100644 --- a/test/integration/services/ApplicationSettings.ts +++ b/test/integration/services/ApplicationSettings.ts @@ -6,7 +6,6 @@ beforeAll(async () => { service = new ApplicationSettings({ host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }); }); diff --git a/test/integration/services/Issues.ts b/test/integration/services/Issues.ts index d95d66df4..e6e9cae14 100644 --- a/test/integration/services/Issues.ts +++ b/test/integration/services/Issues.ts @@ -3,7 +3,6 @@ import { Issues, Projects } from '../../../src'; const config = { host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }; let project; let service: Issues; diff --git a/test/integration/services/Projects.ts b/test/integration/services/Projects.ts index 4a7d2348f..8e81a7f2b 100644 --- a/test/integration/services/Projects.ts +++ b/test/integration/services/Projects.ts @@ -6,7 +6,6 @@ beforeEach(() => { service = new Projects({ host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }); }); diff --git a/test/integration/services/PushRule.ts b/test/integration/services/PushRule.ts index 4a2092154..563ea058d 100644 --- a/test/integration/services/PushRule.ts +++ b/test/integration/services/PushRule.ts @@ -6,7 +6,6 @@ describe('PushRule.edit', () => { const service = new PushRule({ host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }); const result = await service.edit(1, { diff --git a/test/integration/services/Snippets.ts b/test/integration/services/Snippets.ts index 119e88e99..e4070b0f3 100644 --- a/test/integration/services/Snippets.ts +++ b/test/integration/services/Snippets.ts @@ -6,7 +6,6 @@ beforeEach(() => { service = new Snippets({ host: process.env.GITLAB_URL, token: process.env.PERSONAL_ACCESS_TOKEN, - rejectUnauthorized: false, // Testing with localhost }); });