fix(core): Improve logging consistency, record update functionality, and API error handling in Cloudflare modules
This commit is contained in:
@@ -7,6 +7,11 @@ export interface IWorkerRoute extends interfaces.ICflareWorkerRoute {
|
||||
zoneName: string;
|
||||
}
|
||||
|
||||
export interface IWorkerRouteDefinition {
|
||||
zoneName: string;
|
||||
pattern: string;
|
||||
}
|
||||
|
||||
export class CloudflareWorker {
|
||||
// STATIC
|
||||
public static async fromApiObject(
|
||||
@@ -46,9 +51,8 @@ export class CloudflareWorker {
|
||||
result: interfaces.ICflareWorkerRoute[];
|
||||
} = await this.workerManager.cfAccount.request('GET', requestRoute);
|
||||
for (const route of response.result) {
|
||||
console.log('hey');
|
||||
console.log(route);
|
||||
console.log(this.id);
|
||||
logger.log('debug', `Processing route: ${route.pattern}`);
|
||||
logger.log('debug', `Comparing script: ${route.script} with worker ID: ${this.id}`);
|
||||
if (route.script === this.id) {
|
||||
this.routes.push({ ...route, zoneName: zone.name });
|
||||
}
|
||||
@@ -56,7 +60,11 @@ export class CloudflareWorker {
|
||||
}
|
||||
}
|
||||
|
||||
public async setRoutes(routeArray: Array<{ zoneName: string; pattern: string }>) {
|
||||
/**
|
||||
* Sets routes for this worker
|
||||
* @param routeArray Array of route definitions
|
||||
*/
|
||||
public async setRoutes(routeArray: IWorkerRouteDefinition[]) {
|
||||
for (const newRoute of routeArray) {
|
||||
// lets determine wether a route is new, needs an update or already up to date.
|
||||
let routeStatus: 'new' | 'needsUpdate' | 'alreadyUpToDate' = 'new';
|
||||
@@ -90,4 +98,4 @@ export class CloudflareWorker {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user