Skip to content

Commit c69b167

Browse files
authored
feat(error-retry): add flag to disable retry on error and align readme (#108)
1 parent 18a8118 commit c69b167

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

README.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# contentful-management.js
2+
3+
> JavaScript SDK for [Contentful's](https://www.contentful.com) Content Management API.
4+
15
[![npm](https://img.shields.io/npm/v/contentful-management.svg)](https://www.npmjs.com/package/contentful-management)
26
[![Build Status](https://travis-ci.org/contentful/contentful-management.js.svg?branch=master)](https://travis-ci.org/contentful/contentful-management.js)
37
[![Coverage Status](https://coveralls.io/repos/github/contentful/contentful-management.js/badge.svg?branch=master)](https://coveralls.io/github/contentful/contentful-management.js?branch=master)
@@ -8,10 +12,6 @@
812
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
913
[![npm downloads](https://img.shields.io/npm/dm/contentful-management.svg)](http://npm-stat.com/charts.html?package=contentful-management)
1014

11-
Javascript SDK for [Contentful's](https://www.contentful.com) Content Management API.
12-
13-
# About
14-
1515
[Contentful](https://www.contentful.com) is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via a powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.
1616

1717
## Features
@@ -150,19 +150,57 @@ You can try and change the above example at [Tonic](https://tonicdev.com/npm/con
150150
- Check your internet connection
151151
- It is called `contentful-management` and not `contenful-management` ¯\_(ツ)_/¯
152152
- **Can I use it with typescript?**
153-
- Yes, type definition file coming soon
153+
- Yes, type definition file coming soon
154154
- **I am not sure what payload to send when creating and entity (Asset/Entity/ContentType etc...)**
155155
- Check the Content Management API [docs](https://www.contentful.com/developers/docs/references/content-management-api/) or the examples in the reference [docs](https://contentful.github.io/contentful-management.js)
156156
- Feel free to open an issue if you didn't find what you need in the above links
157-
- 😱 **something is wrong what should I do**
158-
- If it is a bug related to the code create a Github issue and make sure to remove any credential for your code before sharing it.
157+
- 😱 **something is wrong what should I do**
158+
- If it is a bug related to the code create a GitHub issue and make sure to remove any credential for your code before sharing it.
159159
- If you need to share your credentials, for example you have an issue with your space, please create a support ticket.
160-
- Please **do not** share your management token in a Github issue
161-
160+
- Please **do not** share your management token in a GitHub issue
161+
162162
## Documentation/References
163163

164164
To help you get the most out of this SDK, we've prepared reference documentation, tutorials and other examples that will help you learn and understand how to use this library.
165165

166+
### Configuration
167+
168+
The `createClient` method supports several options you may set to achieve the expected behavior:
169+
170+
```js
171+
contentful.createClient({
172+
... your config here ...
173+
})
174+
```
175+
176+
#### accessToken (required)
177+
Your CMA access token.
178+
179+
#### host (default: `'api.contentful.com'`)
180+
Set the host used to build the request URI's.
181+
182+
#### hostUpload (default: `'upload.contentful.com'`)
183+
Set the host used to build the upload related request uri's.
184+
185+
#### httpAgent (default: `undefined`)
186+
Custom agent to perform HTTP requests. Find further information in the [axios request config documentation](https://github.com/mzabriskie/axios#request-config).
187+
188+
#### httpsAgent (default: `undefined`)
189+
Custom agent to perform HTTPS requests. Find further information in the [axios request config documentation](https://github.com/mzabriskie/axios#request-config).
190+
191+
#### headers (default: `[]`)
192+
Additional headers to attach to the requests. We add/overwrite the following headers:
193+
194+
* Content-Type: `application/vnd.contentful.management.v1+json`
195+
* X-Contentful-User-Agent: `sdk contentful-management.js/1.2.3; platform node.js/1.2.3; os macOS/1.2.3`
196+
(Automatically generated)
197+
198+
#### proxy (default: `undefined`)
199+
Axios proxy configuration. See the [axios request config documentation](https://github.com/mzabriskie/axios#request-config) for further information about the supported values.
200+
201+
#### retryOnError (default: `true`)
202+
By default, this SDK is retrying requests which resulted in a 500 server error and 429 rate limit response. Set this to `false` to disable this behavior.
203+
166204
### Reference documentation
167205

168206
The [Contentful's JS SDK reference](https://contentful.github.io/contentful-management.js) documents what objects and methods are exposed by this library, what arguments they expect and what kind of data is returned.
@@ -177,7 +215,7 @@ The `ContentfulSpaceAPI` namespace defines the methods at the Space level which
177215

178216
The `Entry`, `Asset` and `ContentType` namespaces show you the instance methods you can use on each of these entities, once you retrieve them from the server.
179217

180-
From version 1.0.0 onwards, you can access documentation for a specific version by visiting `https://contentful.github.io/contentful-management.js/contentful-management/<VERSION>`
218+
> From version 1.0.0 onwards, you can access documentation for a specific version by visiting `https://contentful.github.io/contentful-management.js/contentful-management/<VERSION>`
181219
182220
### Contentful JavaScript resources
183221

@@ -207,7 +245,7 @@ See the [migration guide](MIGRATION.md) for more information.
207245

208246
## Support
209247

210-
If you have a problem with this library, please file an [issue](https://github.com/contentful/contentful-management.js/issues/new) here on Github.
248+
If you have a problem with this library, please file an [issue](https://github.com/contentful/contentful-management.js/issues/new) here on GitHub.
211249

212250
If you have other problems with Contentful not related to this library, you can contact [Customer Support](https://support.contentful.com).
213251

lib/contentful-management.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import createContentfulApi from './create-contentful-api'
1212
import version from '../version'
1313
/**
1414
* @typedef {ContentfulManagement} ContentfulManagement
15-
* @property {function(params: {accessToken: string, insecure?: boolean, host?: string, hostUpload?: string, httpAgent?: Object, httpsAgent?: Object, headers?: Object, proxy?:Object, application?: string, integration?: string}): ClientAPI} createClient - Create a client instance, this is the entry point to the library
15+
* @property {function(params: {accessToken: string, insecure?: boolean, host?: string, hostUpload?: string, httpAgent?: Object, httpsAgent?: Object, headers?: Object, proxy?:Object, application?: string, integration?: string}, retryOnError?: boolean): ClientAPI} createClient - Create a client instance, this is the entry point to the library
1616
*
1717
* @example
1818
* // require contentful-management

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
],
5656
"dependencies": {
5757
"axios": "~0.15.3",
58-
"contentful-sdk-core": "^3.10.1",
58+
"contentful-sdk-core": "^3.11.0",
5959
"es6-promise": "^4.0.5",
6060
"lodash": "^4.17.4",
6161
"platform": "1.3.3"

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,9 @@ content-type@~1.0.2:
13791379
version "1.0.2"
13801380
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed"
13811381

1382-
contentful-sdk-core@^3.10.1:
1383-
version "3.10.1"
1384-
resolved "https://registry.yarnpkg.com/contentful-sdk-core/-/contentful-sdk-core-3.10.1.tgz#9a9149711fbe628a8deeae405681c64dc371fcaa"
1382+
contentful-sdk-core@^3.11.0:
1383+
version "3.11.0"
1384+
resolved "https://registry.yarnpkg.com/contentful-sdk-core/-/contentful-sdk-core-3.11.0.tgz#79d8fd637fb512072ad7f412d25204340c6623ca"
13851385
dependencies:
13861386
axios "^0.15.3"
13871387
es6-promise "^4.0.5"

0 commit comments

Comments
 (0)