You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# CONTRIBUTING
2
2
3
-
Contributions are always welcome, no matter how large or small. Before contributing, please read the [code of conduct](CODE_OF_CONDUCT.md).
3
+
Contributions are always welcome, no matter how large or small. Before contributing, please read the
4
+
[code of conduct](CODE_OF_CONDUCT.md).
4
5
5
6
## Setup
6
7
@@ -17,7 +18,8 @@ You can also use yarn.
17
18
18
19
## Testing
19
20
20
-
This repo uses [ava](https://github.com/avajs/ava) for testing. Any files in the `src` directory that have a `.test.js` file extension are automatically detected and run as tests.
21
+
This repo uses [ava](https://github.com/avajs/ava) for testing. Any files in the `src` directory that have a `.test.js`
22
+
file extension are automatically detected and run as tests.
21
23
22
24
We also test for a few other things:
23
25
@@ -28,9 +30,11 @@ We also test for a few other things:
28
30
29
31
## Architecture
30
32
31
-
We target Node.js LTS and stable environments, and aim for basic modern browser support when possible. In order to facilitate simple contributions, we avoided any kind of build steps.
33
+
We target Node.js LTS and stable environments, and aim for basic modern browser support when possible. In order to
34
+
facilitate simple contributions, we avoided any kind of build steps.
32
35
33
-
If you need to add new API routes, please add them to the [open-api](https://github.com/netlify/open-api) repo. This client will automatically inherent the new routes from that module.
36
+
If you need to add new API routes, please add them to the [open-api](https://github.com/netlify/open-api) repo. This
37
+
client will automatically inherent the new routes from that module.
34
38
35
39
Projects that depend heavily on this client that should be taken into consideration when making changes:
36
40
@@ -45,5 +49,5 @@ $ npm publish
45
49
46
50
## License
47
51
48
-
By contributing to Netlify Node Client, you agree that your contributions will be licensed
49
-
under its [MIT license](LICENSE).
52
+
By contributing to Netlify Node Client, you agree that your contributions will be licensed under its
globalParams: {} // parameters you want available for every request.
64
+
globalParams: {},// parameters you want available for every request.
65
65
// Global params are only sent of the OpenAPI spec specifies the provided params.
66
66
}
67
67
```
68
68
69
69
### `client.accessToken`
70
70
71
-
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
71
+
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is
72
+
instantiated, and all subsequent calls will use the newly set `accessToken`.
72
73
73
74
### `client.basePath`
74
75
75
76
A getter that returns the formatted base URL of the endpoint the client is configured to use.
76
77
77
78
### OpenAPI Client methods
78
79
79
-
The client is dynamically generated from the [OpenAPI](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each operation. **To see a list of available operations, please see the [OpenAPI website](https://open-api.netlify.com/)**.
80
+
The client is dynamically generated from the [OpenAPI](https://github.com/netlify/open-api) definition file. Each method
81
+
is is named after the `operationId` name of each operation. **To see a list of available operations, please see the
Performs a call to the given endpoint corresponding with the `operationId`. Returns a promise resolved with the body of the response, or rejected with an error with the details about the request attached. Rejects if the `status` > 400.
88
+
Performs a call to the given endpoint corresponding with the `operationId`. Returns a promise resolved with the body of
89
+
the response, or rejected with an error with the details about the request attached. Rejects if the `status` > 400.
86
90
87
91
-`params` is an object that includes any of the required or optional endpoint parameters.
88
-
-`params.body` should be an object which gets serialized to JSON automatically. Any object can live here but refer to the OpenAPI specification for allowed fields in a particular request body. It can also be a function returning an object.
89
-
- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream or a function returning one (e.g. `() => fs.createReadStream('./foo')`). Using a function is recommended.
92
+
-`params.body` should be an object which gets serialized to JSON automatically. Any object can live here but refer to
93
+
the OpenAPI specification for allowed fields in a particular request body. It can also be a function returning an
94
+
object.
95
+
- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream or a function returning one (e.g.
96
+
`() => fs.createReadStream('./foo')`). Using a function is recommended.
90
97
91
98
```js
92
99
// example params
93
100
constparams= {
94
101
any_param_needed,
95
102
paramsCanAlsoBeCamelCase,
96
103
body: {
97
-
an:'arbitrary js object'
98
-
}
104
+
an:'arbitrary js object',
105
+
},
99
106
}
100
107
```
101
108
102
-
Optional `opts` can include any property you want passed to [`node-fetch`](https://github.com/bitinn/node-fetch). The `headers` property is merged with some `defaultHeaders`.
109
+
Optional `opts` can include any property you want passed to [`node-fetch`](https://github.com/bitinn/node-fetch). The
110
+
`headers` property is merged with some `defaultHeaders`.
103
111
104
112
```js
105
113
// example opts
106
114
constopts= {
107
-
headers: { // Default headers
115
+
headers: {
116
+
// Default headers
108
117
'User-agent':'netlify-js-client',
109
-
accept:'application/json'
110
-
}
118
+
accept:'application/json',
119
+
},
111
120
// any other properties for node-fetch
112
121
}
113
122
```
@@ -128,22 +137,25 @@ async function getSomeData() {
128
137
}
129
138
```
130
139
131
-
If the response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
140
+
If the response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text`
141
+
of the response is returned.
132
142
133
143
### API Flow Methods
134
144
135
145
Some methods have been added in addition to the open API operations that make certain actions simpler to perform.
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
149
+
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the
150
+
response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken`
151
+
and returns `accessToken` for the consumer to save for later.
140
152
141
153
Optional `opts` include:
142
154
143
155
```js
144
156
constopts= {
145
157
poll:1000, // number of ms to wait between polling
146
-
timeout:3.6e6// number of ms to wait before timing out
158
+
timeout:3.6e6,// number of ms to wait before timing out
**Node.js only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the contents of that folder.
169
-
Sometimes this method needs to write to a `tmpDir`. By default `tmpDir` is a folder in the system temporary directory.
180
+
**Node.js only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the
181
+
contents of that folder. Sometimes this method needs to write to a `tmpDir`. By default `tmpDir` is a folder in the
182
+
system temporary directory.
170
183
171
184
The following paths can be passed in the options:
172
185
@@ -186,9 +199,11 @@ const opts = {
186
199
parallelHash:100, // number of parallel hashing calls
187
200
parallelUpload:5, // number of files to upload in parallel
188
201
maxRetry:5, // number of times to try on failed file uploads
189
-
filter:filepath=> { /* return false to filter a file from the deploy */ },
202
+
filter: (filepath) => {
203
+
/* return false to filter a file from the deploy */
204
+
},
190
205
tmpDir:tempy.directory(), // a temporary directory to zip functions into
191
-
statusCb:statusObj=> {
206
+
statusCb:(statusObj)=> {
192
207
// a callback function to receive status events
193
208
// statusObj: {
194
209
// type: name-of-step
@@ -199,13 +214,14 @@ const opts = {
199
214
// for an example of how this can be used.
200
215
},
201
216
// passing a deployId will update an existing deploy based on the provided options
202
-
deployId:null
217
+
deployId:null,
203
218
}
204
219
```
205
220
206
221
## Proxy support
207
222
208
-
**Node.js only**: If this client is used behind a corporate proxy, you can pass an `HttpsProxyAgent` or any other `http.Agent` that can handle your situation as `agent` option:
223
+
**Node.js only**: If this client is used behind a corporate proxy, you can pass an `HttpsProxyAgent` or any other
224
+
`http.Agent` that can handle your situation as `agent` option:
0 commit comments