Skip to content

Commit 848fff3

Browse files
authored
chore: move ApiGateway creation into a factory method (#6058)
1 parent 2dc7c17 commit 848fff3

File tree

1 file changed

+12
-2
lines changed
  • packages/cubejs-server-core/src/core

1 file changed

+12
-2
lines changed

packages/cubejs-server-core/src/core/server.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import LRUCache from 'lru-cache';
55
import isDocker from 'is-docker';
66
import pLimit from 'p-limit';
77

8-
import { ApiGateway, UserBackgroundContext } from '@cubejs-backend/api-gateway';
8+
import { ApiGateway, ApiGatewayOptions, UserBackgroundContext } from '@cubejs-backend/api-gateway';
99
import {
1010
CancelableInterval,
1111
createCancelableInterval, formatDuration, getAnonymousId,
@@ -435,7 +435,7 @@ export class CubejsServerCore {
435435
return this.apiGatewayInstance;
436436
}
437437

438-
return (this.apiGatewayInstance = new ApiGateway(
438+
return (this.apiGatewayInstance = this.createApiGatewayInstance(
439439
this.options.apiSecret,
440440
this.getCompilerApi.bind(this),
441441
this.getOrchestratorApi.bind(this),
@@ -461,6 +461,16 @@ export class CubejsServerCore {
461461
));
462462
}
463463

464+
protected createApiGatewayInstance(
465+
apiSecret: string,
466+
getCompilerApi: (context: RequestContext) => CompilerApi,
467+
getOrchestratorApi: (context: RequestContext) => OrchestratorApi,
468+
logger: LoggerFn,
469+
options: ApiGatewayOptions
470+
): ApiGateway {
471+
return new ApiGateway(apiSecret, getCompilerApi, getOrchestratorApi, logger, options);
472+
}
473+
464474
protected async contextRejectionMiddleware(req, res, next) {
465475
if (!this.standalone) {
466476
const result = this.contextAcceptor.shouldAcceptHttp(req.context);

0 commit comments

Comments
 (0)