Muthu Kumar
7 years ago
commit
e6eecf24cc
7 changed files with 87 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||
node_modules |
|||
config.js |
|||
samples.js |
@ -0,0 +1,27 @@ |
|||
const axios = require('axios'); |
|||
|
|||
const { |
|||
token |
|||
} = require('./config') |
|||
|
|||
const domainList = require('./lib/domains/list'); |
|||
const domainCreate = require('./lib/domains/create'); |
|||
const domainRetrieve = require('./lib/domains/retrieve'); |
|||
const domainDelete = require('./lib/domains/deleteDomain'); |
|||
|
|||
const instance = axios.create({ |
|||
baseURL: 'https://api.digitalocean.com/v2', |
|||
timeout: 10000, |
|||
headers: { |
|||
'Authorization': `Bearer ${token}` |
|||
} |
|||
}); |
|||
|
|||
const domain = { |
|||
List: (instance) => domainList(instance), |
|||
Create: (instance, domainObject) => domainCreate(instance, domainObject), |
|||
Retrieve: (instance, domainName) => domainRetrieve(instance, domainName), |
|||
Delete: (instance, domainName) => domainDelete(instance, domainName), |
|||
}; |
|||
|
|||
module.exports.domain = domain; |
@ -0,0 +1,9 @@ |
|||
const Create = async (instance, domainObject) => { |
|||
res = await instance.post('/domains', { |
|||
"name": domainObject.name, |
|||
"ip_address": domainObject.ip, |
|||
}); |
|||
return (res.data); |
|||
}; |
|||
|
|||
module.exports = Create; |
@ -0,0 +1,9 @@ |
|||
const Delete = async (instance, domainObject) => { |
|||
res = await instance.post(`/domains`, { |
|||
"name": domainObject.name, |
|||
"ip_address": domainObject.ip, |
|||
}); |
|||
return (res.data); |
|||
}; |
|||
|
|||
module.exports = Delete; |
@ -0,0 +1,6 @@ |
|||
const List = async (instance) => { |
|||
res = await instance.get(`/domains`); |
|||
return(res.data); |
|||
}; |
|||
|
|||
module.exports = List; |
@ -0,0 +1,6 @@ |
|||
const Delete = async (instance, domainName) => { |
|||
res = await instance.post(`/domains/${domainName}`); |
|||
return (res.data); |
|||
}; |
|||
|
|||
module.exports = Delete; |
@ -0,0 +1,27 @@ |
|||
{ |
|||
"name": "do-node", |
|||
"version": "0.1.0", |
|||
"description": "A (partial) DigitalOcean wrapper for Node.", |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"test": "echo \"Error: no test specified\" && exit 1" |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/codefeathers/do-node.git" |
|||
}, |
|||
"keywords": [ |
|||
"DigitalOcean", |
|||
"node", |
|||
"javascript" |
|||
], |
|||
"author": "Muthu Kumar (https://mkr.pw)", |
|||
"license": "MIT", |
|||
"bugs": { |
|||
"url": "https://github.com/codefeathers/do-node/issues" |
|||
}, |
|||
"homepage": "https://github.com/codefeathers/do-node#readme", |
|||
"dependencies": { |
|||
"axios": "^0.17.1" |
|||
} |
|||
} |
Loading…
Reference in new issue