Skip to content
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
70 changes: 70 additions & 0 deletions .github/workflows/deploy-proxy-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Deploy Proxy Server

on:
workflow_dispatch:

env:
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
REGION: ${{ vars.GCP_REGION }}
SERVICE_NAME: ${{ vars.GCP_SERVICE_NAME }}
SUPERDOC_SERVICES_API_KEY: ${{ secrets.SUPERDOC_SERVICES_API_KEY }}
SUPERDOC_SERVICES_BASE_URL: ${{ vars.SUPERDOC_SERVICES_BASE_URL }}

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Auth to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ env.PROJECT_ID }}

- name: Build and push container with Cloud Build
run: |
REGION="${REGION:-us-central1}"
SERVICE_NAME="${SERVICE_NAME:-esign-demo-proxy-server}"
IMAGE="gcr.io/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA}"

echo "REGION=${REGION}" >> $GITHUB_ENV
echo "SERVICE_NAME=${SERVICE_NAME}" >> $GITHUB_ENV
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV

gcloud builds submit demo/server --tag "${IMAGE}"
env:
PROJECT_ID: ${{ env.PROJECT_ID }}
REGION: ${{ env.REGION }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}

- name: Deploy container to Cloud Run
run: |
REGION="${REGION:-us-central1}"
SERVICE_NAME="${SERVICE_NAME:-esign-demo-proxy-server}"
IMAGE="${IMAGE}"
SUPERDOC_SERVICES_BASE_URL="${SUPERDOC_SERVICES_BASE_URL:-https://api.superdoc.dev}"

gcloud run deploy "${SERVICE_NAME}" \
--image "${IMAGE}" \
--region "${REGION}" \
--memory=1Gi \
--cpu=1 \
--allow-unauthenticated \
--set-env-vars SUPERDOC_SERVICES_BASE_URL="${SUPERDOC_SERVICES_BASE_URL}" \
--set-secrets="SUPERDOC_SERVICES_API_KEY=esign-demo-sd-services-api-key:latest"
env:
IMAGE: ${{ env.IMAGE }}
REGION: ${{ env.REGION }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
SUPERDOC_SERVICES_API_KEY: ${{ env.SUPERDOC_SERVICES_API_KEY }}
SUPERDOC_SERVICES_BASE_URL: ${{ env.SUPERDOC_SERVICES_BASE_URL }}
51 changes: 51 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Demo

This demo shows how to integrate `@superdoc-dev/esign` into a React application. The frontend sends signing and download requests to a proxy server, which securely communicates with the SuperDoc Services API.

## Prerequisites

You'll need a SuperDoc Services API key. [Get your API key here](https://docs.superdoc.dev/api-reference/authentication/register).

## Setup

1. Build the main package (from repo root):
```bash
pnpm build
```

2. Install dependencies:
```bash
cd demo
pnpm install
cd server
pnpm install
```

3. Create `.env` file in `demo/server/`:
```
SUPERDOC_SERVICES_API_KEY=your_key_here
```

4. Update `demo/vite.config.ts` to proxy to localhost:
```ts
proxy: {
'/v1': {
target: 'http://localhost:3001',
changeOrigin: true,
},
},
```

## Running

Start the proxy server:
```bash
cd demo/server
pnpm start
```

In a separate terminal, start the frontend:
```bash
cd demo
pnpm dev
```
1 change: 1 addition & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@superdoc-dev/esign": "link:../.",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"signature_pad": "^5.1.1",
"superdoc": "^0.35.3"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions demo/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions demo/server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
npm-debug.log
.env
.env.*
Dockerfile
.dockerignore
3 changes: 3 additions & 0 deletions demo/server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PORT=3003
SUPERDOC_SERVICES_API_KEY=replace-with-your-superdoc-api-key
SUPERDOC_SERVICES_BASE_URL=https://api.superdoc.dev
13 changes: 13 additions & 0 deletions demo/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

WORKDIR /app

COPY package.json ./
RUN corepack enable && pnpm install --prod --no-lockfile

COPY . .

# Cloud Run/Functions set PORT; default to 8080
ENV PORT=8080

CMD ["pnpm", "start"]
15 changes: 15 additions & 0 deletions demo/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "esign-proxy-server",
"private": true,
"type": "module",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "node server.js"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2"
}
}
Loading
Loading