Skip to content

Commit

Permalink
chore: config feature flags on run time (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Apr 29, 2024
1 parent c915e58 commit 946c06a
Show file tree
Hide file tree
Showing 63 changed files with 567 additions and 379 deletions.
3 changes: 0 additions & 3 deletions .env

This file was deleted.

8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ FROM node:18-alpine
WORKDIR /usr/src/app
COPY --from=base /usr/src/app/dist /usr/src/app/dist
COPY --from=base /usr/src/app/package*.json ./
COPY --from=base /usr/src/app/replace_env.sh ./
COPY --from=base /usr/src/app/.env ./

RUN apk add --no-cache bash

RUN ls -l /usr/src/app/dist

RUN chmod +x replace_env.sh
EXPOSE 8080 9000
CMD [ "/bin/bash", "-c", "/usr/src/app/replace_env.sh && yarn serve" ]
CMD [ "/bin/bash", "-c", "yarn serve" ]
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Follow these simple steps to set up Hyperswitch on your local machine.

### Running with Docker

1. `docker run -p 9000:9000 -e apiBaseUrl=your-backend-url -e sdkBaseUrl=your-sdk-url juspaydotin/hyperswitch-control-center:latest`
1. `docker run -p 9000:9000 -e default__endpoints__api_url=your-backend-url -e default__endpoints__sdk_url=your-sdk-url juspaydotin/hyperswitch-control-center:latest`

### Accessing the Application

Expand All @@ -80,7 +80,7 @@ Feature flags allow the users to enable or disable certain functionalities or fl

### Using feature flags

The FeatureFlag.json file can be found under config/FeatueFlag.json. By default, all the feature flags are turned off (`False` value).
The config.toml file can be found under config/config.toml. By default, all the feature flags are turned off (`False` value).

### Feature flag descriptions

Expand Down Expand Up @@ -131,6 +131,7 @@ The `test_live_toggle` feature flag enables users to toggle between test and liv
#### Is Live Mode

The `is_live_mode` feature flag enables the live mode - that the user is accessing. When enabled, it will show a visual indicator within the dashboard signaling whether the user is currently in a test environment or live production environment.
In Live mode, current users are not allowed to sign up. Users must be created manually.

#### Email

Expand All @@ -148,11 +149,41 @@ The `surcharge` feature flag enables the ability to apply surcharges to payments

Enabling `user_journey_analytics` grants access to the user journey module within the analytics section of the dashboard. This feature provides comprehensive graphical representations of payment analytics, facilitating a deeper understanding of user behavior and usage patterns.

### Branding

Enabling `branding` feature flag enables customization of branding elements like logos, colors.

---

## Deployment
## Customize the Color and Logo

Priamry color,logo and favicon can customizied by setting the values in the config.toml

```
[default.theme]
primary_color="#006DF9"
primary_hover_color="#005ED6"
sidebar_color="#242F48"
[default.endpoints]
logo_url=""
favicon_url=""
```

## Enable the features on Run time by overriding the default value

You can override these default values either by exporting them directly

```
export default__theme__sidebar_color="#3b0764";
export default__features__threeds_authenticator=true;
export default__features__is_live_mode=true;
```

Or, you can set these values as environment variables by defining them in the `.env` file and pass the file
during the docker run command

You can deploy the application to a hosting platform like Netlify, Vercel, or Firebase Hosting. Configure the deployment settings as needed for your chosen platform.
`docker run -p 9000:9000 --env-file=.env juspaydotin/hyperswitch-control-center:latest`

### Deploy on AWS cloud

Expand Down
4 changes: 2 additions & 2 deletions aws/hyperswitch_control_center_aws_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
docker pull juspaydotin/hyperswitch-control-center:v1.0.0
docker pull juspaydotin/hyperswitch-control-center:latest
docker run -p 80:9000 -e apiBaseUrl=${apiBaseUrl} -e sdkBaseUrl=${sdkBaseUrl} juspaydotin/hyperswitch-control-center:v1.0.0
docker run -p 80:9000 -e default__endpoint__api_url=${apiBaseUrl} -e default__endpoint__sdk_url=${sdkBaseUrl} juspaydotin/hyperswitch-control-center:latest
EOF

Expand Down
24 changes: 0 additions & 24 deletions config/FeatureFlag.json
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
{
"test_live_toggle": false,
"is_live_mode": false,
"email": false,
"quick_start": false,
"audit_trail": false,
"system_metrics": false,
"sample_data": false,
"frm": false,
"payout": true,
"recon": false,
"test_processors": true,
"feedback": false,
"mixpanel": false,
"generate_report": false,
"user_journey_analytics": false,
"surcharge": false,
"dispute_evidence_upload": false,
"paypal_automatic_flow": false,
"threeds-authenticator": false,
"global_search": false,
"dispute_analytics": false,
"configure_pmts": false
}
35 changes: 35 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[default.theme]
primary_color="#006DF9"
primary_hover_color="#005ED6"
sidebar_color="#242F48"
[default.endpoints]
api_url="http://localhost:8080"
sdk_url=""
logo_url=""
favicon_url=""
mixpanel_token=""
[default.features]
test_live_toggle=false
is_live_mode=false
email=false
quick_start=false
audit_trail=false
system_metrics=false
sample_data=false
frm=false
payout=true
recon=false
test_processors=true
feedback=false
mixpanel=false
generate_report=false
user_journey_analytics=false
surcharge=false
dispute_evidence_upload=false
paypal_automatic_flow=false
threeds_authenticator=false
global_search=false
dispute_analytics=false
configure_pmts=false
branding=false

73 changes: 42 additions & 31 deletions cypress/e2e/auth/auth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe("Auth Module", () => {
cy.get("[data-testid=email]").type(username);
cy.get("[data-testid=password]").type(password);
cy.get('button[type="submit"]').click({ force: true });
cy.url().should("eq", "http://localhost:9000/home");
cy.url().should("eq", "http://localhost:9000/dashboard/home");
});

it("check the components in the login page", () => {
cy.visit("http://localhost:9000/login");
cy.visit("http://localhost:9000/dashboard/login");
cy.url().should("include", "/login");
cy.get("#card-header").should("contain", "Hey there, Welcome back!");
cy.get("#card-subtitle").should("contain", "Sign up");
Expand All @@ -38,36 +38,50 @@ describe("Auth Module", () => {
cy.url().should("include", "/register");
cy.get("#card-header").should("contain", "Welcome to Hyperswitch");
cy.get("#card-subtitle").should("contain", "Sign in");
cy.go("back");
cy.get("#card-subtitle").click();
cy.url().should("include", "/login");
cy.get("#card-header").should("contain", "Hey there, Welcome back!");
});

it("sets true the feature flag for magic link and forgot password,then checks auth page back button functioning", () => {
cy.intercept("POST", "/config/merchant-access", {
cy.intercept("GET", "merchant-config?domain=default", {
statusCode: 200,
body: {
test_live_toggle: false,
is_live_mode: false,
email: true,
quick_start: false,
audit_trail: false,
system_metrics: false,
sample_data: false,
frm: false,
payout: true,
recon: false,
test_processors: true,
feedback: false,
mixpanel: false,
generate_report: false,
user_journey_analytics: false,
surcharge: false,
permission_based_module: false,
dispute_evidence_upload: false,
paypal_automatic_flow: false,
invite_multiple: false,
"accept-invite": false,
theme: {
primary_color: "#006DF9",
primary_hover_color: "#005ED6",
sidebar_color: "#242F48",
},
endpoints: {
api_url: "http://localhost:8080",
sdk_url: "",
logo_url: "",
favicon_url: "",
mixpanel_token: "",
},
features: {
test_live_toggle: false,
is_live_mode: false,
email: true,
quick_start: false,
audit_trail: false,
system_metrics: false,
sample_data: false,
frm: false,
payout: true,
recon: false,
test_processors: true,
feedback: false,
mixpanel: false,
generate_report: false,
user_journey_analytics: false,
surcharge: false,
permission_based_module: false,
dispute_evidence_upload: false,
paypal_automatic_flow: false,
invite_multiple: false,
"accept-invite": false,
},
},
}).as("getFeatureData");
cy.visit("http://localhost:9000");
Expand All @@ -79,18 +93,15 @@ describe("Auth Module", () => {
cy.get("[data-testid=forgot-password]").click();
cy.url().should("include", "/forget-password");
cy.get("#card-header").should("contain", "Forgot Password?");
cy.go("back");
cy.url().should("include", "/login");
cy.get("#card-header").should("contain", "Hey there, Welcome back!");
});

it("should successfully log in with valid credentials", () => {
const password = "cypress98#";
cy.visit("http://localhost:9000/login");
cy.visit("http://localhost:9000/dashboard/login");
cy.get("[data-testid=email]").type(username);
cy.get("[data-testid=password]").type(password);
cy.get('button[type="submit"]').click({ force: true });
cy.url().should("eq", "http://localhost:9000/home");
cy.url().should("eq", "http://localhost:9000/dashboard/home");
});

it("should display an error message with invalid credentials", () => {
Expand All @@ -107,6 +118,6 @@ describe("Auth Module", () => {
cy.get("[data-testid=email]").type(` ${username} `);
cy.get("[data-testid=password]").type(password);
cy.get('button[type="submit"]').click({ force: true });
cy.url().should("eq", "http://localhost:9000/home");
cy.url().should("eq", "http://localhost:9000/dashboard/home");
});
});
64 changes: 39 additions & 25 deletions cypress/e2e/quick-start/prod-quick-start.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,51 @@ before(() => {
cy.singup_curl(username, "cypress98#");
});
beforeEach(() => {
cy.intercept("POST", "/config/merchant-access", {
cy.intercept("GET", "merchant-config?domain=default", {
statusCode: 200,
body: {
test_live_toggle: false,
is_live_mode: true,
email: false,
quick_start: false,
audit_trail: false,
system_metrics: false,
sample_data: false,
frm: false,
payout: true,
recon: false,
test_processors: false,
feedback: false,
mixpanel: false,
generate_report: false,
user_journey_analytics: false,
surcharge: false,
permission_based_module: false,
dispute_evidence_upload: false,
paypal_automatic_flow: false,
invite_multiple: false,
"accept-invite": false,
theme: {
primary_color: "#006DF9",
primary_hover_color: "#005ED6",
sidebar_color: "#242F48",
},
endpoints: {
api_url: "http://localhost:8080",
sdk_url: "",
logo_url: "",
favicon_url: "",
mixpanel_token: "",
},
features: {
test_live_toggle: false,
is_live_mode: true,
email: false,
quick_start: false,
audit_trail: false,
system_metrics: false,
sample_data: false,
frm: false,
payout: true,
recon: false,
test_processors: false,
feedback: false,
mixpanel: false,
generate_report: false,
user_journey_analytics: false,
surcharge: false,
permission_based_module: false,
dispute_evidence_upload: false,
paypal_automatic_flow: false,
invite_multiple: false,
"accept-invite": false,
},
},
}).as("getData");
}).as("getFeatureData");
cy.intercept("GET", "/agreement/tc-hyperswitch-aug-23.pdf", {
statusCode: 200,
}).as("getPDF");
cy.visit("http://localhost:9000");
cy.wait("@getData");
cy.wait("@getFeatureData");
cy.login_UI(username, "cypress98#");
cy.wait("@getPDF");
});
Expand Down Expand Up @@ -107,6 +121,6 @@ describe("Prod quick start", () => {
cy.get("[data-button-for=connectAndProceed]").click({ force: true });
cy.contains("Basic Account Setup Successful");
cy.get("[data-button-for=goToDashboard]").click({ force: true });
cy.url().should("eq", "http://localhost:9000/home");
cy.url().should("eq", "http://localhost:9000/dashboard/home");
});
});
Loading

0 comments on commit 946c06a

Please sign in to comment.