MCPcopy
hub / github.com/microfeed/microfeed / _updateEnvVars

Method _updateEnvVars

ops/sync_project_config.js:53–94  ·  view source on GitHub ↗
(data, onSuccess)

Source from the content-addressed store, hash-verified

51 }
52
53 _updateEnvVars(data, onSuccess) {
54 const options = {
55 hostname: 'api.cloudflare.com',
56 port: 443,
57 path: `/client/v4/accounts/${this.v.get('CLOUDFLARE_ACCOUNT_ID')}/pages/projects/${this.v.get('CLOUDFLARE_PROJECT_NAME')}`,
58 method: 'PATCH',
59 headers: {
60 'Authorization': `Bearer ${this.v.get('CLOUDFLARE_API_TOKEN')}`,
61 'Content-Type': 'application/json',
62 'Content-Length': data.length,
63 },
64 };
65
66 const req = https.request(options, (res) => {
67 // console.log('statusCode:', res.statusCode);
68 // console.log('headers:', res.headers);
69 let body = '';
70 res.on('data', (d) => {
71 // d.result.deployment_configs.preview
72 // d.result.deployment_configs.production
73 // process.stdout.write(d);
74 // onSuccess(d);
75 body += d;
76 });
77 res.on("end", () => {
78 try {
79 let json = JSON.parse(body);
80 onSuccess(json);
81 } catch (error) {
82 console.error(error.message);
83 process.exit(1);
84 }
85 });
86 });
87
88 req.on('error', (e) => {
89 console.error(e);
90 process.exit(1);
91 });
92 req.write(data)
93 req.end();
94 }
95
96 syncEnvVars() {
97 console.log(`Sync-ing for [${this.currentEnv}]...`);

Callers 1

syncEnvVarsMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected