61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
const http = require('https');
|
|
|
|
const API_KEY = '4|lL3pgQVbfLb6KtUByDLaswjP4Jccny8HMj5jrs0v4ace4e78';
|
|
const APP_UUID = 'e91cvmd4gqohmd8p53dmo2wq';
|
|
|
|
const request = (method, path, data = null) => {
|
|
return new Promise((resolve, reject) => {
|
|
const options = {
|
|
hostname: 'deploy.digifox.live',
|
|
port: 443,
|
|
path: path,
|
|
method: method,
|
|
headers: {
|
|
'Authorization': `Bearer ${API_KEY}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
};
|
|
|
|
if (data) {
|
|
options.headers['Content-Length'] = Buffer.byteLength(data);
|
|
}
|
|
|
|
const req = http.request(options, res => {
|
|
let body = '';
|
|
res.on('data', d => body += d);
|
|
res.on('end', () => resolve({ status: res.statusCode, body }));
|
|
});
|
|
|
|
req.on('error', error => reject(error));
|
|
|
|
if (data) {
|
|
req.write(data);
|
|
}
|
|
req.end();
|
|
});
|
|
};
|
|
|
|
async function run() {
|
|
try {
|
|
const data = JSON.stringify({
|
|
docker_compose_domains: JSON.stringify({
|
|
ui: {
|
|
domain: "https://aisop.houseofwebsites.ai"
|
|
}
|
|
})
|
|
});
|
|
|
|
console.log('Patching domains to the UI service...');
|
|
const res = await request('PATCH', `/api/v1/applications/${APP_UUID}`, data);
|
|
console.log('Status:', res.status, res.body);
|
|
|
|
console.log('Triggering deployment to apply domain changes...');
|
|
const deployRes = await request('POST', `/api/v1/applications/${APP_UUID}/start`);
|
|
console.log('Deploy Status:', deployRes.status, deployRes.body);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
}
|
|
}
|
|
|
|
run();
|