Created
January 12, 2018 21:27
-
-
Save tizzo/aa228326e9b73ab81484004c917f2f7a to your computer and use it in GitHub Desktop.
Programatic Cloudmine Deploys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
var request = require('request'); | |
request = request.defaults({jar: true}); | |
// The appid from the hosted app. | |
const appid = 'XXX'; | |
const body = { | |
email: 'someone@somewhere.com', | |
password: 'XXX', | |
} | |
const headers = { | |
'Origin': 'https://compass.cloudmine.io', | |
}; | |
request.post({uri: 'https://compass.cloudmine.io/dashboard/v1/user/login', body, headers, json: true}, (error, response, body) => { | |
console.log(error, response.statusCode, body); | |
const formData = { | |
file: { | |
value: fs.createReadStream('hosted-app.zip'), | |
options: { | |
filename: 'hosted-app.zip', | |
contentType: 'application/zip' | |
} | |
} | |
}; | |
request.post({uri: `https://compass.cloudmine.io/dashboard/v1/site/${appid}/upload`, headers, formData}, (error, response, body) => { | |
console.log(error, response.statusCode, body); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const request = require('request'); | |
// This is your the user id of the user performing the deploy, this can be found by posting to `https://compass.cloudmine.io/dashboard/v1/user/login` with a username and password. | |
const devid = 'XXX'; | |
// This is the master API key findable in the UI. | |
const apikey = 'XXX'; | |
// This is the app id of the logic engine app you want to deploy to. | |
const appid = 'XXX'; | |
const formData = { | |
devid, | |
apikey, | |
file: { | |
value: fs.createReadStream('logic-engine.zip'), | |
options: { | |
filename: 'logic-engine.zip', | |
contentType: 'application/zip' | |
} | |
} | |
}; | |
const qs = { apikey, devid }; | |
const uri = `https://api.secure.cloudmine.me/admin/app/${appid}/code/upload/node`; | |
request.post({uri, formData, qs}, (error, response, body) => { | |
// This prints `null 200 '{"names":[]}'` if everything goes right. | |
console.log(error, response.statusCode, body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment