From d7a2d520b6068286a7e3eeff324e3e0c7990b408 Mon Sep 17 00:00:00 2001 From: hwhung Date: Thu, 7 May 2026 18:27:58 +0800 Subject: [PATCH] Use web artifact publish path --- .replit | 6 +----- readme.md | 18 +++++++++--------- replit.md | 7 +++---- setup.md | 47 ++++++++++++++++++++++++++++++++--------------- src/lib/config.ts | 2 +- 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/.replit b/.replit index 9422bc3..4de0457 100644 --- a/.replit +++ b/.replit @@ -1,6 +1,2 @@ -run = "node build.mjs && PORT=${PORT:-3000} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} node --enable-source-maps dist/index.mjs" +run = "node build.mjs && PORT=${PORT:-3001} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} node --enable-source-maps dist/index.mjs" onBoot = "pnpm install --ignore-workspace" - -[deployment] -build = ["sh", "-c", "pnpm install --ignore-workspace && pnpm build:fast"] -run = ["sh", "-c", "PORT=${PORT:-3000} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} NODE_ENV=production node --enable-source-maps dist/index.mjs"] diff --git a/readme.md b/readme.md index ceb681b..6e615e1 100644 --- a/readme.md +++ b/readme.md @@ -18,10 +18,10 @@ The `.replit` `onBoot` command installs dependencies with: pnpm install --ignore-workspace ``` -For publishing from a workspace that clones this repo into `./random-proxy-simple`, configure the -workspace root `.replit` `[deployment]` block to build and run `random-proxy-simple` directly. -Keep `PORT`, `PROXY_API_KEY`, and `NODE_ENV` in the production `run` command. Do not use artifact -production deployment for this proxy. Use `pnpm build:fast` for Replit publish builds. +For publishing from a workspace that clones this repo into `./random-proxy-simple`, create a +`kind = "web"` artifact and point its production build/run commands at this proxy. Do not publish +this proxy as a `kind = "api"` artifact and do not rely on root `.replit` deployment settings. +Use `pnpm build:fast` for Replit publish builds. ## Install @@ -36,7 +36,7 @@ Use the available `pnpm`. This repo intentionally has no `packageManager` pin. ## Start ```bash -pnpm dev +node build.mjs && PORT=${PORT:-3001} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} node --enable-source-maps dist/index.mjs ``` When Replit AI Integrations are provisioned, the app reads these variables automatically: @@ -61,7 +61,7 @@ Use Replit AI Integrations endpoints only. Never use public official provider en ## Defaults - host: `0.0.0.0` -- port: `3000` +- port: `3001` - bearer token: `dev-proxy-key` These can be overridden with CLI flags or environment variables: @@ -76,9 +76,9 @@ Integration provider values are read from the `AI_INTEGRATIONS_*` environment va ## Verify ```bash -curl -s http://localhost:3000/api/healthz -curl -s http://localhost:3000/dashboard | head -curl -s -H "Authorization: Bearer ${PROXY_API_KEY:-dev-proxy-key}" http://localhost:3000/v1/models +curl -s http://localhost:3001/api/healthz +curl -s http://localhost:3001/dashboard | head +curl -s -H "Authorization: Bearer ${PROXY_API_KEY:-dev-proxy-key}" http://localhost:3001/v1/models ``` Expected without provider flags: dashboard, health, and model list work; chat completions return `503`. diff --git a/replit.md b/replit.md index 51fade2..34ccac0 100644 --- a/replit.md +++ b/replit.md @@ -2,7 +2,7 @@ ## Overview -Standalone TypeScript API server with Replit run and deployment configuration. +Standalone TypeScript API server with Replit run configuration. ## Stack @@ -33,7 +33,7 @@ Never use public official provider endpoints. ## Key Commands - `pnpm install --ignore-workspace` — install dependencies without joining a parent workspace -- `pnpm dev` — run API server locally on port `3000` +- `pnpm dev` — run API server locally on port `3001` - `pnpm run typecheck` — typecheck the server - `pnpm run build` — typecheck and build `dist/index.mjs` - `pnpm run build:fast` — build `dist/index.mjs` without typechecking @@ -43,8 +43,7 @@ Never use public official provider endpoints. - `.replit` `run` builds with `node build.mjs` and runs `dist/index.mjs` - `.replit` `onBoot` uses `pnpm install --ignore-workspace` -- deployment build uses `pnpm install --ignore-workspace && pnpm build:fast` -- deployment run uses `node --enable-source-maps dist/index.mjs` +- publishing should use a `kind = "web"` artifact with production build/run commands pointing at this proxy ## Server Overrides diff --git a/setup.md b/setup.md index bef9ef7..0c0e88f 100644 --- a/setup.md +++ b/setup.md @@ -1,6 +1,7 @@ Clone and run https://git.komnenos.me/springfw/random-proxy-simple in ./random-proxy-simple. -Goal: get the app running once on port 3000 with OpenAI and Anthropic Replit AI Integrations wired. +Goal: get the app running once on port 3001 with OpenAI and Anthropic Replit AI Integrations wired, +and make it publishable. Bearer token for this deployment: DEPLOYMENT_GENERATED_PROXY_TOKEN @@ -11,7 +12,7 @@ AI_INTEGRATIONS_* variables; they are not OAuth connectors. Do not: - add it to a parent workspace -- move it into artifacts/ +- move the proxy repo into artifacts/ - modify source files - edit package.json - create config.json or /tmp config files @@ -25,10 +26,8 @@ Do not: - run a foreground server command directly in the shell - run verification commands - run chat-completion smoke tests unless asked - -Publishability requirement: do not configure production deployment through the artifact system. -Configure the workspace root .replit [deployment] section to build and run the cloned proxy -directly. +- configure production deployment through the root .replit [deployment] section +- create or publish a kind = "api" artifact for this proxy Steps: @@ -44,23 +43,41 @@ skills: 4. Create the smallest persistent workflow named "Random Proxy Simple" with this exact run command: - cd /home/runner/workspace/random-proxy-simple && node build.mjs && PORT=3000 PROXY_API_KEY=DEPLOYMENT_GENERATED_PROXY_TOKEN node --enable-source-maps dist/index.mjs + cd /home/runner/workspace/random-proxy-simple && node build.mjs && PORT=3001 PROXY_API_KEY=DEPLOYMENT_GENERATED_PROXY_TOKEN node --enable-source-maps dist/index.mjs 5. Start/restart that workflow once. -6. Configure the workspace root .replit [deployment] section exactly like this: +6. Create a new react-vite artifact at previewPath = "/". Keep its artifact kind as "web"; this is +the publishable signal Replit needs. Do not convert it to kind = "api". - [deployment] - build = ["sh", "-c", "cd random-proxy-simple && pnpm install --ignore-workspace && pnpm build:fast"] - run = ["sh", "-c", "cd random-proxy-simple && PORT=3000 PROXY_API_KEY=DEPLOYMENT_GENERATED_PROXY_TOKEN NODE_ENV=production node --enable-source-maps dist/index.mjs"] +7. Use verifyAndReplaceArtifactToml on that web artifact. Preserve the artifact's existing +kind/title/id/integratedSkills metadata. Replace only the service production config so it builds +and runs the proxy: -7. If artifacts/mockup-sandbox exists in the Replit workspace, leave it as-is. Do not create, -move, or configure this proxy repo as a mockup-sandbox artifact. + [services.production] -8. Do not run health, dashboard, model-list, or chat-completion verification commands. + [services.production.build] + args = ["sh", "-c", "cd random-proxy-simple && pnpm install --ignore-workspace && pnpm build:fast"] + + [services.production.run] + args = ["sh", "-c", "cd random-proxy-simple && PORT=3001 PROXY_API_KEY=DEPLOYMENT_GENERATED_PROXY_TOKEN NODE_ENV=production node --enable-source-maps dist/index.mjs"] + + [services.env] + PORT = "3001" + PROXY_API_KEY = "DEPLOYMENT_GENERATED_PROXY_TOKEN" + NODE_ENV = "production" + + [services.production.health.startup] + path = "/api/healthz" + +8. If artifacts/mockup-sandbox exists, keep it as its own artifact and configure its production +mode to serve a static Vite build from artifacts/mockup-sandbox/dist. Do not move or configure +this proxy repo as mockup-sandbox. + +9. Do not run health, dashboard, model-list, or chat-completion verification commands. Report only: - local URL - whether setupReplitAIIntegrations wired OpenAI and Anthropic -- whether the workspace root .replit [deployment] build/run commands were configured +- whether a kind = "web" artifact was configured with proxy production build/run commands - that no verification commands were run diff --git a/src/lib/config.ts b/src/lib/config.ts index 4e4d7b7..fe75d13 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -24,7 +24,7 @@ export interface AppConfig { const DEFAULT_CONFIG: AppConfig = { server: { host: "0.0.0.0", - port: 3000, + port: 3001, }, proxy: { apiKey: "dev-proxy-key",