Skip to content

waxz/itty-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

itty-adapter

Make itty-router work with Hono Adapter. Get ENV in Bun, Deno, Node, Cloudflare Workers

import type { IRequest } from "itty-router/"
import { Router } from "itty-router/Router"
import { env, getRuntimeKey } from "../../src/adapter.ts"
import { Context } from "../../src/context.ts"

const app = Router<IRequest>()

app.get("/", (req:Request,ctx:Context) => {

 const {NAME}  = env<{NAME: string }>(ctx);
 console.log(`get ENV NAME: ${NAME}`)

  return new Response(`hello ${NAME}` ,{
    status : 200
  })


})
export { app }

Run On Local

deno

install deno

curl -fsSL https://deno.land/install.sh | sh
source ~/.bashrc

build

deno task build

run

export NAME=tom
deno task start

node

node dist/main_node.mjs

bun

npx bun dist/main_bun.mjs

deploy to cloudflare workers/pages

deno task build
mkdir -p cf
cp ./dist/main_cloudflare-workers.mjs ./cf/_worker.js
npx wrangler dev ./cf/_worker.js --name itty-test --compatibility-date 2025-10-04 --port 8000


npx wrangler deploy ./cf/_worker.js --name itty-test --compatibility-date 2025-10-04

npx wrangler pages deploy ./cf --project-name itty-test

Reference:

https://github.com/zuisong/gemini-openai-proxy https://github.com/honojs/hono

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published