Skip to content

Commit

Permalink
changes from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Nov 27, 2024
1 parent f525028 commit 04f0c9f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"fmt:check": "biome check src",
"ts:check": "tsc",
"e2e": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" yarn run cypress open --config baseUrl='http://localhost:3000' --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"e2e:oss": "yarn --cwd frontend run cypress run --spec \"cypress/oss/**/*.spec.ts\" --config baseUrl=\"http://localhost:${EXPOSED_PORT:-4242}\" --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"e2e:oss": "yarn cypress run --spec \"cypress/oss/**/*.spec.ts\" --config baseUrl=\"http://localhost:${EXPOSED_PORT:-4242}\" --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"e2e:heroku": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" yarn run cypress open --config baseUrl='https://unleash.herokuapp.com' --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"gen:api": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" orval --config orval.config.js",
"gen:api:demo": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://app.unleash-hosted.com/demo/docs/openapi.json yarn run gen:api",
Expand Down
1 change: 1 addition & 0 deletions src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ exports[`should create default config 1`] = `
},
"inlineSegmentConstraints": true,
"isEnterprise": false,
"isOss": false,
"listen": {
"host": undefined,
"port": 4242,
Expand Down
3 changes: 3 additions & 0 deletions src/lib/create-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
Boolean(options.enterpriseVersion) &&
ui.environment?.toLowerCase() !== 'pro';

const isTest = process.env.NODE_ENV === 'test';
const isOss = !isEnterprise && ui.environment !== 'pro' && !isTest;
const metricsRateLimiting = loadMetricsRateLimitingConfig(options);

const rateLimiting = loadRateLimitingConfig(options);
Expand Down Expand Up @@ -760,6 +762,7 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
publicFolder: options.publicFolder,
disableScheduler: options.disableScheduler,
isEnterprise: isEnterprise,
isOss: isOss,
metricsRateLimiting,
rateLimiting,
feedbackUriPath,
Expand Down
9 changes: 2 additions & 7 deletions src/lib/db/feature-environment-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export class FeatureEnvironmentStore implements IFeatureEnvironmentStore {
constructor(
db: Db,
eventBus: EventEmitter,
{
getLogger,
ui,
isEnterprise,
}: Pick<IUnleashConfig, 'getLogger' | 'ui' | 'isEnterprise'>,
{ getLogger, isOss }: Pick<IUnleashConfig, 'getLogger' | 'isOss'>,
) {
this.db = db;
this.logger = getLogger('feature-environment-store.ts');
Expand All @@ -54,8 +50,7 @@ export class FeatureEnvironmentStore implements IFeatureEnvironmentStore {
store: 'feature-environments',
action,
});
const isTest = process.env.NODE_ENV === 'test';
this.isOss = !isEnterprise && ui.environment !== 'pro' && !isTest;
this.isOss = isOss;
}

async delete({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ export default class FeatureToggleClientStore
{
getLogger,
flagResolver,
ui,
isEnterprise,
}: Pick<
IUnleashConfig,
'getLogger' | 'flagResolver' | 'ui' | 'isEnterprise'
>,
isOss,
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver' | 'isOss'>,
) {
this.db = db;
this.logger = getLogger('feature-toggle-client-store.ts');
Expand All @@ -70,8 +66,7 @@ export default class FeatureToggleClientStore
action,
});
this.flagResolver = flagResolver;
const isTest = process.env.NODE_ENV === 'test';
this.isOss = !isEnterprise && ui.environment !== 'pro' && !isTest;
this.isOss = isOss;
}

private async getAll({
Expand All @@ -84,7 +79,6 @@ export default class FeatureToggleClientStore
const isPlayground = requestType === 'playground';
const environment = featureQuery?.environment || DEFAULT_ENV;
const stopTimer = this.timer(`getAllBy${requestType}`);
this.logger.info(`Getting all features and we're OSS: ${this.isOss}`);
let selectColumns = [
'features.name as name',
'features.description as description',
Expand Down
9 changes: 2 additions & 7 deletions src/lib/features/project-environments/environment-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,11 @@ export default class EnvironmentStore implements IEnvironmentStore {
constructor(
db: Db,
eventBus: EventEmitter,
{
getLogger,
isEnterprise,
ui,
}: Pick<IUnleashConfig, 'getLogger' | 'isEnterprise' | 'ui'>,
{ getLogger, isOss }: Pick<IUnleashConfig, 'getLogger' | 'isOss'>,
) {
this.db = db;
this.logger = getLogger('db/environment-store.ts');
const isTest = process.env.NODE_ENV === 'test';
this.isOss = !isEnterprise && ui.environment !== 'pro' && !isTest;
this.isOss = isOss;
this.timer = (action) =>
metricsHelper.wrapTimer(eventBus, DB_TIME, {
store: 'environment',
Expand Down
11 changes: 3 additions & 8 deletions src/lib/features/project/project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,8 @@ class ProjectStore implements IProjectStore {
{
getLogger,
flagResolver,
ui,
isEnterprise,
}: Pick<
IUnleashConfig,
'getLogger' | 'flagResolver' | 'ui' | 'isEnterprise'
>,
isOss,
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver' | 'isOss'>,
) {
this.db = db;
this.logger = getLogger('project-store.ts');
Expand All @@ -96,8 +92,7 @@ class ProjectStore implements IProjectStore {
action,
});
this.flagResolver = flagResolver;
const isTest = process.env.NODE_ENV === 'test';
this.isOss = !isEnterprise && ui.environment !== 'pro' && !isTest;
this.isOss = isOss;
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export interface IUnleashConfig {
publicFolder?: string;
disableScheduler?: boolean;
isEnterprise: boolean;
isOss: boolean;
rateLimiting: IRateLimiting;
feedbackUriPath?: string;
openAIAPIKey?: string;
Expand Down

0 comments on commit 04f0c9f

Please sign in to comment.