A portable TypeScript service exposing identical HTTP endpoints across Cloudflare Workers, AWS Lambda, and Google Cloud Run.
This project is part of the Corelib monorepo and is tightly coupled with @ckir/corelib and @ckir/corelib-markets, utilizing their core abstractions for database connectivity, resilient HTTP requests, and structured logging.
Hono application instance shared across all platforms.@ckir/corelib's endPoint utility for proxied requests with built-in retries and timeouts.@ckir/corelib-markets.StrictLogger for edge environments that outputs structured JSON to console.log.src/
├── core/
│ ├── router.ts # Shared Hono application logic and routes
│ └── logger.ts # Edge-optimized structured logger
├── retrieve/
│ └── RequestUnlimitedCloud.ts # Generic HTTP proxy router
├── markets/
│ └── nasdaq/
│ └── ApiNasdaqUnlimitedCloud.ts # Nasdaq-specific proxy router
└── platform/
├── cloudflare/ # Cloudflare Worker entry point
├── aws/ # AWS Lambda (ESM) handler
└── cloudrun/ # Google Cloud Run (Node.js) server
GET /health: Returns system status and current platform.POST /api/v1/ky: Generic resilient HTTP proxy.POST /api/v1/markets/nasdaq: Nasdaq-specific resilient market data proxy.curl https://your-service-url/health
Expose corelib's resilient fetching logic via the /api/v1/ky endpoint.
curl -X POST https://your-service-url/api/v1/ky \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.github.com/zen"
}'
curl -X POST https://your-service-url/api/v1/ky \
-H "Content-Type: application/json" \
-d '{
"endPoints": [
{ "url": "https://api.a.com/status" },
{ "url": "https://api.b.com/data", "options": { "timeout": 2000 } }
]
}'
Specialized proxy for Nasdaq API calls. Enforces correct browser-like headers and provides automatic retries.
curl -X POST https://your-service-url/api/v1/markets/nasdaq \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.nasdaq.com/api/quote/AAPL/info?assetclass=stocks"
}'
curl -X POST https://your-service-url/api/v1/markets/nasdaq \
-H "Content-Type: application/json" \
-d '{
"endPoints": [
{ "url": "https://api.nasdaq.com/api/quote/AAPL/info?assetclass=stocks" },
{ "url": "https://api.nasdaq.com/api/quote/MSFT/info?assetclass=stocks" }
]
}'
Ensure the Corelib monorepo dependencies are installed:
pnpm install
Run the service locally using Wrangler and Vitest:
# Start local dev server
pnpm run dev
# Run worker-specific tests
pnpm run test:worker
Build all three platform-specific bundles into the dist/ directory:
pnpm run build
This generates:
dist/cloudflare/worker.js: Optimized ESM bundle for Cloudflare Workers.dist/aws/handler.js: ESM bundle for AWS Lambda (Node 24+).dist/cloudrun/server.js: ESM bundle for Google Cloud Run (Node 24+).pnpm exec wrangler deploy src/platform/cloudflare/worker.ts
pnpm run buildcd dist/aws && zip -r function.zip handler.jsaws lambda update-function-code --function-name YOUR_FUNC --zip-file fileb://function.zipDeploy from the generated bundle:
gcloud run deploy ts-cloud \
--source . \
--command "node" \
--args "dist/cloudrun/server.js"
The service expects the following environment variables (where applicable):
CORELIB_TURSO_URL: The URL of your Turso database.CORELIB_TURSO_TOKEN: The authentication token for Turso.PORT: (Cloud Run only) The port the server should listen on (defaults to 3000).