Easy and nice to trans vultr v2 API into JS Object, 100 lines of code in one file
- Wrap all vultr router to object
- Use routing, http protocol methods, path parameters, etc. to combine into a JS Class
-
- Routes are escaped into object structures in order
-
- "-" strings in routes are escaped to camelCase
-
- Routes with n parameters are escaped into sequential parameters in the function in order
- get => no path param .get() | .getById(param1,data) has one param | .getById(param1,param2mdata) has two param
- post => no path param .post() | .postById(param1,data) has one param | .postById(param1,param2mdata) has two param
- put ...
- patch ...
- delete ...
- https://api.vultr.com/v2/load-balancers post Create Load Balancer
- =>
let myVultr = new Vultr(tokenApi)
let r = await myVultr.loadBalancers.post(data)
npm i vultr-v2
const Vultr = require('vultr-v2')
const tokenApi = 'Your tokenKey'
async function main() {
let myVultr = new Vultr(tokenApi) // 实例化
console.log(myVultr.router.length)
let result = await myVultr.loadBalancers.get() // 获取负载均衡列表
console.log(result)
// result = await vultr1.loadBalancers.getById('Your load-balancer-id') // 获取负载均衡详情
// console.log(result)
}
main()
:-)