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
18 changes: 18 additions & 0 deletions examples/x402-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# x402 demo server — public 402 paywall ($0.001 USDC on Base Sepolia).
# Deployed as a CodeSpar example API so agents can pay a real 402 resource.
# Env (set in Railway, NOT baked in): SERVER_ADDRESS (payee 0x), FACILITATOR_URL.
# Do NOT copy .env into the image — it holds the example CLIENT_PRIVATE_KEY.
FROM node:22-slim
WORKDIR /app

COPY package.json ./
# Full install (not --omit=dev): the server runs via `tsx`, a devDependency.
RUN npm install --no-audit --no-fund

COPY server.ts ./

# Railway injects PORT; the server reads process.env.PORT (fallback 4021).
ENV PORT=4021
EXPOSE 4021

CMD ["npx", "tsx", "server.ts"]
14 changes: 14 additions & 0 deletions examples/x402-demo/railway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://railway.com/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "Dockerfile",
"watchPatterns": ["examples/x402-demo/**"]
},
"deploy": {
"healthcheckPath": "/api/health",
"healthcheckTimeout": 10,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 3
}
}
2 changes: 1 addition & 1 deletion examples/x402-demo/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ app.get("/api/premium-analysis", (_req, res) => {
});
});

const PORT = 4021;
const PORT = Number(process.env.PORT) || 4021;
app.listen(PORT, () => {
console.log(`\n x402 Demo Server running on http://localhost:${PORT}`);
console.log(` Network: Base Sepolia (eip155:84532)`);
Expand Down
Loading