Skip to content

Commit

Permalink
lift returned value to Promise to simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmroz-allegro committed Oct 19, 2022
1 parent e8b49e6 commit 2845020
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/server/utils/cluster-manager/cluster-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { External } from "plywood";
import { PlywoodRequester } from "plywood-base-api";
import { Decoration, DecoratorRequest, DruidRequestDecorator } from "plywood-druid-requester";
import { DecoratorRequest, DruidRequestDecorator } from "plywood-druid-requester";
import { Logger } from "../../../common/logger/logger";
import { Cluster, makeExternalFromSourceName, shouldScanSources } from "../../../common/models/cluster/cluster";
import { constant, noop } from "../../../common/utils/functional/functional";
Expand Down Expand Up @@ -185,13 +185,7 @@ export class ClusterManager {

return (request: DecoratorRequest, context: object) => {
const decoration = requestDecorator(request, context);
const mergeAuthHeaders = (d: Decoration): Decoration => Object.assign(d, authHeaders);

if ("then" in decoration && typeof decoration.then === "function") {
return decoration.then(mergeAuthHeaders);
}

return mergeAuthHeaders(decoration as Decoration);
return Promise.resolve(decoration).then(d => Object.assign(d, authHeaders));
};

}
Expand Down

0 comments on commit 2845020

Please sign in to comment.