diff --git a/Hyperswitch-React-Demo-App/.env b/Hyperswitch-React-Demo-App/.env index 6f2b16210..d1e623e52 100644 --- a/Hyperswitch-React-Demo-App/.env +++ b/Hyperswitch-React-Demo-App/.env @@ -1,7 +1,7 @@ -STATIC_DIR="./public" -HYPERSWITCH_PUBLISHABLE_KEY="GET_PUBLISHABLE_KEY_FROM_DASHBOARD" -HYPERSWITCH_SECRET_KEY="GET_SECRET_KEY_FROM_DASHBOARD" -HYPERSWITCH_SERVER_URL="SELF_HOSTED_SERVER_URL" -HYPERSWITCH_CLIENT_URL="SELF_HOSTED_CLIENT_URL" -SELF_SERVER_URL="ENTER_YOUR_SERVER_APPLICATION_URL" -SELF_CLIENT_URL="ENTER_YOUR_CLIENT_APPLICATION_URL" \ No newline at end of file +STATIC_DIR=./dist +HYPERSWITCH_PUBLISHABLE_KEY= +HYPERSWITCH_SECRET_KEY= +HYPERSWITCH_SERVER_URL= +HYPERSWITCH_CLIENT_URL= +SELF_SERVER_URL= +SELF_CLIENT_URL= \ No newline at end of file diff --git a/Hyperswitch-React-Demo-App/Dockerfile b/Hyperswitch-React-Demo-App/Dockerfile new file mode 100644 index 000000000..af56f12e5 --- /dev/null +++ b/Hyperswitch-React-Demo-App/Dockerfile @@ -0,0 +1,9 @@ + +FROM node:18-alpine +WORKDIR /usr/src/app +COPY package*.json ./ +COPY . . +RUN yarn install +RUN yarn build +CMD [ "yarn" ,"start-server" ] + diff --git a/Hyperswitch-React-Demo-App/Makefile b/Hyperswitch-React-Demo-App/Makefile new file mode 100644 index 000000000..114c7b734 --- /dev/null +++ b/Hyperswitch-React-Demo-App/Makefile @@ -0,0 +1,19 @@ +NS ?= juspaydotin +VERSION ?= v1.0.0 +IMAGE_NAME ?= hyperswitch-web +BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) +CONTAINER_NAME ?= hyperswitch-web +CONTAINER_INSTANCE ?= default +SOURCE_COMMIT := $(shell git rev-parse HEAD) +RUN_TEST ?= false +.PHONY: build push shell run start stop rm release +build: Dockerfile + $(info Building $(NS)/$(IMAGE_NAME):$(VERSION) / git-head: $(SOURCE_COMMIT)) + $(info git branch is $(BRANCH_NAME)) + # cp -R ~/.ssh . + docker build --platform=linux/amd64 -t $(IMAGE_NAME):$(VERSION) -f Dockerfile . +# aws-auth: +# aws ecr get-login-password --region $(REGION) | docker login --username AWS --password-stdin $(ACCOUNT_ID).dkr.ecr.$(REGION).amazonaws.com +push: + docker tag $(IMAGE_NAME):$(VERSION) $(NS)/$(IMAGE_NAME):$(VERSION) + docker push $(NS)/$(IMAGE_NAME):$(VERSION) \ No newline at end of file diff --git a/Hyperswitch-React-Demo-App/package.json b/Hyperswitch-React-Demo-App/package.json index 1584bcc3f..8b624eae5 100644 --- a/Hyperswitch-React-Demo-App/package.json +++ b/Hyperswitch-React-Demo-App/package.json @@ -25,7 +25,7 @@ "scripts": { "start": "concurrently \"npm run start-client\" \"npm run start-server\"", "start-client": " webpack --config webpack.dev.js && webpack serve --config webpack.dev.js", - "start-server": "node server.js", + "start-server": "node dist/server.js", "build": "webpack --config webpack.common.js", "test": "react-scripts test", "eject": "react-scripts eject", @@ -64,4 +64,4 @@ "webpack-bundle-analyzer": "^4.8.0", "webpack-dev-server": "^3.11.3" } -} +} \ No newline at end of file diff --git a/Hyperswitch-React-Demo-App/server.js b/Hyperswitch-React-Demo-App/server.js index 92b8db3c9..00c5bb103 100644 --- a/Hyperswitch-React-Demo-App/server.js +++ b/Hyperswitch-React-Demo-App/server.js @@ -5,12 +5,15 @@ const { resolve } = require("path"); // Replace if using a different env file or config const env = require("dotenv").config({ path: "./.env" }); -app.use(express.static(process.env.STATIC_DIR)); +app.use(express.static("./dist")); app.get("/", (req, res) => { - const path = resolve(process.env.STATIC_DIR + "/index.html"); + const path = resolve("./dist" + "/index.html"); + res.sendFile(path); +}); +app.get("/completion", (req, res) => { + const path = resolve("./dist" + "/index.html"); res.sendFile(path); }); - // replace the test api key with your hyperswitch api key const hyper = require("@juspay-tech/hyperswitch-node")( process.env.HYPERSWITCH_SECRET_KEY diff --git a/Hyperswitch-React-Demo-App/webpack.dev.js b/Hyperswitch-React-Demo-App/webpack.dev.js index 9368ac4af..5d8dc22d0 100644 --- a/Hyperswitch-React-Demo-App/webpack.dev.js +++ b/Hyperswitch-React-Demo-App/webpack.dev.js @@ -21,7 +21,7 @@ let devServer = { }; module.exports = merge([ - common("/payments"), + common("/"), { mode: "development", devServer: devServer,