do api started
This commit is contained in:
parent
360f2c591d
commit
63b7a3b481
41
doapi.js
41
doapi.js
@ -2,50 +2,29 @@ var request = require('request');
|
||||
|
||||
|
||||
api = function(key){
|
||||
if(!key){
|
||||
key = require('./secrets.js').doAPI;
|
||||
}
|
||||
this.url = 'https://digitalocean.com/v2/';
|
||||
key = key || require('./secrets.js').doAPI;
|
||||
this.BASEURL = 'https://api.digitalocean.com/v2/';
|
||||
|
||||
this.headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer '+key
|
||||
}
|
||||
|
||||
this.byTag: function(tag, callback){
|
||||
this.byTag = function(tag, callback){
|
||||
var options = {
|
||||
url: this.url+'droplets?tag_name='+tag,
|
||||
url: this.BASEURL+'droplets?tag_name='+tag,
|
||||
headers: this.headers
|
||||
}
|
||||
|
||||
return request.get(options, function(error, response, body){
|
||||
return callback(body, response, error);
|
||||
})
|
||||
};
|
||||
|
||||
this.setTag: function(id, tag, callback){
|
||||
return request.post(url+)
|
||||
};
|
||||
// this.setTag = function(id, tag, callback){
|
||||
// return request.post(url+)
|
||||
// };
|
||||
return this;
|
||||
}
|
||||
|
||||
api = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var httpOptions = {
|
||||
url:'http://' + ip + ':15000',
|
||||
body: JSON.stringify({
|
||||
code: req.body.code
|
||||
})
|
||||
};
|
||||
|
||||
return request.post(httpOptions, function(error, response, body){
|
||||
body = JSON.parse(body);
|
||||
body['ip'] = ip.replace('10.0.', '');
|
||||
return res.json(body);
|
||||
});
|
||||
|
||||
module.exports = api;
|
Loading…
x
Reference in New Issue
Block a user