Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: locally connect documentation #335

Merged
merged 18 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ENV_BACKEND_URL=""
ENV_LOGGING_URL=""
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1242,4 +1242,4 @@

### Features

* updated Readme ([427f8fd](https://github.com/juspay/hyperswitch-web/commit/427f8fd91be58fc63b0fa4ab326d562a4caaabab))
* updated Readme ([427f8fd](https://github.com/juspay/hyperswitch-web/commit/427f8fd91be58fc63b0fa4ab326d562a4caaabab))
PritishBudhiraja marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,21 @@ Ways to get started with Hyperswitch:

Before you start the local setup, you will need an understanding of few keys -

### About Env Configs
### About Env Configs for Demo App

- `HYPERSWITCH_PUBLISHABLE_KEY` - Publishable key of your Hyperswitch Account. This key will start with `pk_dev_` for local development, `pk_snd_` for sandbox and `pk_prd_` for production.
- `HYPERSWITCH_SECRET_KEY` - API key of your Hyperswitch Account
- `HYPERSWITCH_SERVER_URL` - URL of your hosted Hyperswitch Backend server or you can use our Sandbox URL (https://sandbox.hyperswitch.io) or use your backend running locally (eg. http://localhost:8080).
- `HYPERSWITCH_CLIENT_URL` - URL of your hosted Hyperswitch SDK or you can use our Sandbox URL (https://beta.hyperswitch.io/v1) or use your app running locally (eg http://localhost:9050).
- **`HYPERSWITCH_PUBLISHABLE_KEY`:** The publishable key of your Hyperswitch account. This key will start with `pk_dev_` for local development, `pk_snd_` for sandbox, and `pk_prd_` for production.

- **`HYPERSWITCH_SECRET_KEY`:** The API key of your Hyperswitch account.

- **`HYPERSWITCH_SERVER_URL`:** The URL of your hosted Hyperswitch backend server. Alternatively, you can use our Sandbox URL (https://sandbox.hyperswitch.io) or specify your backend running locally (e.g., http://localhost:8080).

- **`HYPERSWITCH_CLIENT_URL`:** The URL of your hosted Hyperswitch SDK. You can also use our Sandbox URL (https://beta.hyperswitch.io/v1) or specify your app running locally (e.g., http://localhost:9050).

### About Env Configs for SDK

- **`ENV_BACKEND_URL`:** Sets the endpoint for all the APIs used within the SDK to interact with the backend service. If you are running your own backend service, you can configure and specify its endpoint here for local setups.

- **`ENV_LOGGING_URL`:** Specifies a custom logging endpoint where logs generated by the SDK can be sent. This allows you to view and manage logs according to your requirements.

### Setup Node

Expand Down
25 changes: 15 additions & 10 deletions webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
const webpack = require("webpack");
const path = require("path");
const dotenv = require("dotenv").config();
const tailwindcss = require("tailwindcss");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");

const sdkEnv = process.env.sdkEnv;
const envSdkUrl = process.env.envSdkUrl;
const envBackendUrl = process.env.envBackendUrl;
const envLoggingUrl = process.env.envLoggingUrl;
const sdkEnv = process.env.sdkEnv ?? "local";
const envSdkUrl = process.env.ENV_SDK_URL ?? "";
const envBackendUrl = process.env.ENV_BACKEND_URL ?? "";
const envLoggingUrl = process.env.ENV_LOGGING_URL ?? "";

//git rev-parse --abbrev-ref HEAD
let repoVersion = require("./package.json").version;
let majorVersion = "v" + repoVersion.split(".")[0];

let repoName = require("./package.json").name;
let repoPublicPath = sdkEnv === "local" ? "" : `/${repoVersion}/${majorVersion}`;
let repoPublicPath =
sdkEnv === "local" ? "" : `/${repoVersion}/${majorVersion}`;

let sdkUrl;

if (envSdkUrl === undefined) {
if (envSdkUrl.length === 0) {
sdkUrl =
sdkEnv === "prod"
? "https://checkout.hyperswitch.io"
Expand All @@ -36,7 +39,7 @@ if (envSdkUrl === undefined) {
}

let backendEndPoint;
if (envBackendUrl === undefined) {
if (envBackendUrl.length === 0) {
backendEndPoint =
sdkEnv === "prod"
? "https://checkout.hyperswitch.io/api"
Expand All @@ -50,7 +53,7 @@ if (envBackendUrl === undefined) {
}

let confirmEndPoint;
if (envBackendUrl === undefined) {
if (envBackendUrl.length === 0) {
confirmEndPoint =
sdkEnv === "prod"
? "https://api.hyperswitch.io"
Expand All @@ -64,7 +67,7 @@ if (envBackendUrl === undefined) {
}

let logEndpoint;
if (envLoggingUrl === undefined) {
if (envLoggingUrl.length === 0) {
logEndpoint =
sdkEnv === "prod"
? "https://api.hyperswitch.io/logs/sdk"
Expand Down Expand Up @@ -98,6 +101,7 @@ module.exports = (publicPath = "auto") => {
clean: true,
publicPath: `${repoPublicPath}/`,
},
// TODO - Can be commented for faster build in local development
optimization: {
sideEffects: true,
minimize: true,
Expand Down Expand Up @@ -155,6 +159,7 @@ module.exports = (publicPath = "auto") => {
// new webpack.HTMLInjectPlugin({
// publicPath: JSON.stringify(repoVersion),
// }),
// TODO - Can be commented if sentry not needed.
sentryWebpackPlugin({
org: "sentry",
project: "hyperswitch-react-sdk",
Expand Down
4 changes: 2 additions & 2 deletions webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require("path");
const dotenv = require("dotenv").config();
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");

const sdkEnv = process.env.sdkEnv;
const sdkEnv = process.env.sdkEnv ?? "local";

let backendEndPoint =
sdkEnv === "prod"
Expand Down
Loading