Update README to reflect TypeScript source structure and dev workflow
This commit is contained in:
parent
2e21d1a407
commit
3a921deb27
39
README.md
39
README.md
@ -6,6 +6,8 @@ Services like Square can deliver webhooks but cannot add custom HTTP headers lik
|
|||||||
|
|
||||||
One proxy serves all projects — routing is driven entirely by environment variables.
|
One proxy serves all projects — routing is driven entirely by environment variables.
|
||||||
|
|
||||||
|
Written in **TypeScript** (`src/server.ts`), compiled to plain JS at build time.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
@ -19,7 +21,7 @@ https://app-proxy.bsidesolutions.net/square
|
|||||||
│
|
│
|
||||||
│ Express server resolves:
|
│ Express server resolves:
|
||||||
│ ROUTE_MAP["/square"] = { apiKeySlot: "square", functionId: "verify_square_webhook" }
|
│ ROUTE_MAP["/square"] = { apiKeySlot: "square", functionId: "verify_square_webhook" }
|
||||||
│ PROJECT_CREDENTIALS["square"] = { project: "staging-crown-x-ms-monet", key: "..." }
|
│ PROJECT_CREDENTIALS["square"] = { project: "staging-crown-x-ms-monet", apiKey: "..." }
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
POST https://appwrite.bsidesolutions.net/v1/functions/verify_square_webhook/executions
|
POST https://appwrite.bsidesolutions.net/v1/functions/verify_square_webhook/executions
|
||||||
@ -33,13 +35,19 @@ Appwrite function runs, returns response, proxy returns it to caller.
|
|||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
### Local
|
### Local development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
# edit .env to fill in PROJECT_CREDENTIALS and ROUTE_MAP
|
# edit .env to fill in PROJECT_CREDENTIALS and ROUTE_MAP
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
# Run with hot-reload TypeScript directly
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# Or build + run compiled output
|
||||||
|
npm run build
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -48,7 +56,7 @@ npm start
|
|||||||
```bash
|
```bash
|
||||||
docker build -t bside-webhook-proxy .
|
docker build -t bside-webhook-proxy .
|
||||||
docker run --rm -p 3012:3012 \
|
docker run --rm -p 3012:3012 \
|
||||||
-e PROJECT_CREDENTIALS='{"square":{"project":"...","key":"..."}}' \
|
-e PROJECT_CREDENTIALS='{"square":{"project":"...","apiKey":"..."}}' \
|
||||||
-e ROUTE_MAP='/square=>{"apiKeySlot":"square","functionId":"verify_square_webhook"}' \
|
-e ROUTE_MAP='/square=>{"apiKeySlot":"square","functionId":"verify_square_webhook"}' \
|
||||||
bside-webhook-proxy
|
bside-webhook-proxy
|
||||||
```
|
```
|
||||||
@ -57,7 +65,7 @@ docker run --rm -p 3012:3012 \
|
|||||||
|
|
||||||
1. In Coolify → **Add New Resource** → **Application** → **Public/Private Repo**
|
1. In Coolify → **Add New Resource** → **Application** → **Public/Private Repo**
|
||||||
2. Point at `bside-solutions/bside-webhook-proxy`
|
2. Point at `bside-solutions/bside-webhook-proxy`
|
||||||
3. Coolify auto-builds the Dockerfile
|
3. Coolify auto-builds the Dockerfile (multi-stage build compiles TypeScript)
|
||||||
4. Set the domain (e.g. `app-proxy.bsidesolutions.net`)
|
4. Set the domain (e.g. `app-proxy.bsidesolutions.net`)
|
||||||
5. Add environment variables (see [Configuration](#configuration))
|
5. Add environment variables (see [Configuration](#configuration))
|
||||||
6. Deploy
|
6. Deploy
|
||||||
@ -161,19 +169,20 @@ No code changes needed.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Local development
|
## Project structure
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
npm start
|
|
||||||
```
|
```
|
||||||
|
bside-webhook-proxy/
|
||||||
To test forwarding:
|
├── src/
|
||||||
|
│ └── server.ts # TypeScript source (Express server)
|
||||||
```bash
|
├── dist/ # Compiled JS output (gitignored)
|
||||||
curl -X POST 'http://localhost:3012/square' \
|
├── server.js # Entry point - requires compiled ./dist/server.js
|
||||||
-H 'Content-Type: application/json' \
|
├── package.json # Build + start scripts, deps
|
||||||
-d '{"test": true}'
|
├── tsconfig.json # TypeScript compiler config
|
||||||
|
├── Dockerfile # Multi-stage build (TypeScript -> JS)
|
||||||
|
├── docker-compose.yml # Example Coolify deploy snippet
|
||||||
|
├── .env.example # Sample env vars
|
||||||
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user