Skip to content

Commit 9bc7dc4

Browse files
committed
Bug fixes vultr#434
1 parent 5d9874e commit 9bc7dc4

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [v2.0.1](https://github.com/vultr/vultr-node/compare/v1.0.4..v2.0.0) (2020-02-25)
4+
### Bug Fixes
5+
* Fixes issue create a dns record parameter missing [#434](https://github.com/vultr/vultr-node/issues/434)
6+
37
## [v2.0.0](https://github.com/vultr/vultr-node/compare/v1.0.4..v2.0.0) (2020-01-11)
48
* Upgrade library to use Vultr API V2 syntax and endpoints. [#388](https://github.com/vultr/vultr-node/issues/388)
59

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vultr/vultr-node",
33
"private": false,
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"description": "Node module to communicate with the Vultr API",
66
"main": "src/index.js",
77
"scripts": {

src/api/dns.js

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ exports.createRecord = {
179179
requestType: 'POST',
180180
apiKeyRequired: true,
181181
parameters: {
182+
'dns-domain': {
183+
type: 'string',
184+
path: true,
185+
required: true
186+
},
182187
name: {
183188
type: 'string',
184189
required: true

src/util.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ exports.makeApiRequest = (config, endpoint, userParameters) => {
1212
if (userParameters !== undefined) {
1313
const { requestType, parameters } = endpoint
1414

15+
// All methods may have path parameters
16+
const pathParams = Object.keys(userParameters).filter(
17+
(key) => parameters[key].path
18+
)
19+
20+
if (pathParams.length) {
21+
pathParams.forEach((param) => {
22+
// Ex. '/bare-metals/{baremetal-id}/ipv4' becomes '/bare-metals/123456/ipv4'
23+
fetchUrl = fetchUrl.replace(`{${param}}`, userParameters[param])
24+
})
25+
}
26+
1527
if (requestType === 'POST') {
1628
// POST requests will just send all data as JSON to the endpoint
1729
options.body = JSON.stringify(userParameters)
1830
options.headers['Content-Type'] = 'application/json'
1931
} else {
20-
// GET, DELETE, PATCH, and PUT may have path parameters
21-
const pathParams = Object.keys(userParameters).filter(
22-
(key) => parameters[key].path
23-
)
24-
25-
if (pathParams.length) {
26-
pathParams.forEach((param) => {
27-
// Ex. '/bare-metals/{baremetal-id}/ipv4' becomes '/bare-metals/123456/ipv4'
28-
fetchUrl = fetchUrl.replace(`{${param}}`, userParameters[param])
29-
})
30-
}
31-
3232
if (requestType === 'GET' || requestType === 'DELETE') {
3333
// GET and DELETE requests may have path parameters as well as query parameters
3434
const queryParams = Object.keys(userParameters)

0 commit comments

Comments
 (0)