fix(worker): Refactor worker script update and creation to use intermediate parameter objects
This commit is contained in:
@@ -23,15 +23,14 @@ export class WorkerManager {
|
||||
|
||||
try {
|
||||
// Use the official client to create/update the worker (upload script content)
|
||||
await this.cfAccount.apiAccount.workers.scripts.content.update(workerName, {
|
||||
// Build params as any to include the script form part without TS errors
|
||||
const contentParams: any = {
|
||||
account_id: this.cfAccount.preselectedAccountId,
|
||||
// name the multipart part for the script code
|
||||
metadata: { body_part: 'script' },
|
||||
/* header to indicate which part contains the script */
|
||||
'CF-WORKER-BODY-PART': 'script',
|
||||
// include the actual script as a form part named 'script'
|
||||
script: workerScript,
|
||||
});
|
||||
};
|
||||
contentParams['CF-WORKER-BODY-PART'] = 'script';
|
||||
contentParams['script'] = workerScript;
|
||||
await this.cfAccount.apiAccount.workers.scripts.content.update(workerName, contentParams);
|
||||
|
||||
// Create a new worker instance
|
||||
const worker = new CloudflareWorker(this);
|
||||
|
||||
Reference in New Issue
Block a user