Skip to content

Commit

Permalink
Deduplicate route data
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak committed Mar 2, 2024
1 parent 0d51c57 commit c68ee00
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ async function deploy(
async () => {
const configRoutes = (config.routes || []) as Route[];
const publishRoutes = [...routeData, ...configRoutes];
const allRoutes = (await listWorkerRoutes(token, accountId)).flat();
const currentRoutes = allRoutes.filter((r) => r.script == name);
const allRouteData = (await listWorkerRoutes(token, accountId)).flat();
const allRoutes = Object.values(allRouteData.reduce((acc, ojb) => { ...acc, [obj.id]: obj }));
const currentRouteData = allRoutes.filter((r) => r.script == name);
const currentRoutes = Object.values(currentRouteData.reduce((acc, ojb) => { ...acc, [obj.id]: obj }));
const addRoutes = attrDifference(publishRoutes, currentRoutes, 'pattern');
const delRoutes = attrDifference(currentRoutes, publishRoutes, 'pattern');
const delRouteData = attrDifference(currentRoutes, publishRoutes, 'pattern');
const delRoutes = Object.values(delRouteData.reduce((acc, ojb) => { ...acc, [obj.id]: obj }));
debug(`Account routes: ${JSON.stringify(allRoutes)}`);
debug(`Worker routes current: ${JSON.stringify(currentRoutes)}`);
debug(`Worker routes requested: ${JSON.stringify(publishRoutes)}`);
Expand Down

0 comments on commit c68ee00

Please sign in to comment.