Skip to content

Commit

Permalink
Merge pull request #2167 from honojs/v4
Browse files Browse the repository at this point in the history
v4
  • Loading branch information
yusukebe committed Feb 9, 2024
2 parents a3dfe0f + 88a82ba commit 2c44ad7
Show file tree
Hide file tree
Showing 176 changed files with 12,527 additions and 5,779 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ RUN curl -fsSL https://gist.githubusercontent.com/LukeChannings/09d53f5c36439104
ENV BUN_INSTALL=/usr/local
RUN curl -fsSL https://bun.sh/install | bash

# Install Lagon
RUN yarn global add @lagon/cli esbuild

WORKDIR /hono
88 changes: 34 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ci
on:
push:
branches: [main, next]
branches: [main, next, v4]
pull_request:
branches: ['*']

Expand All @@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v1
with:
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: npm run format
- run: npm run lint
- run: npm run build
- run: NODE_OPTIONS="--no-warnings" npm test
bun-version: '1.0.25'
- run: bun install
- run: bun run format
- run: bun run lint
- run: bun run build
- run: bun run test

denoify:
name: "Checking if you've done denoify"
Expand All @@ -29,11 +29,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
node-version: '18.x'
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: |
npm run denoify
bun run denoify
if [[ `git status --porcelain` ]]; then
exit 1
fi
Expand All @@ -46,7 +46,7 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: env NAME=Deno deno test --allow-read --allow-env runtime_tests/deno
- run: env NAME=Deno deno test --allow-read --allow-env --allow-write -c runtime_tests/deno/deno.json runtime_tests/deno
- run: deno test -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx
- run: deno test -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx

Expand All @@ -57,33 +57,18 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: '1.0.18'
bun-version: '1.0.25'
- run: bun run test:bun

fastly:
name: 'Fastly Compute'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:fastly

lagon:
name: 'Lagon'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm i -g @lagon/cli@latest esbuild@latest
- run: npm run test:lagon
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:fastly

node:
name: 'Node.js v${{ matrix.node }}'
Expand All @@ -96,42 +81,37 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:node
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:node

wrangler:
name: 'Cloudflare Workers'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:wrangler
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:wrangler

lambda:
name: 'AWS Lambda'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:lambda
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:lambda

lambda-edge:
name: 'Lambda@Edge'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:lambda-edge
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bun run build
- run: bun run test:lambda-edge
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ sandbox
worker
.wrangler

# Bun
bun.lockb

# Logs
logs
*.log
Expand Down
12 changes: 12 additions & 0 deletions .vitest.config/jsx-runtime-default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import config from '../vitest.config'
config.esbuild = {
jsx: 'automatic',
jsxImportSource: __dirname + '/../src/jsx',
}
if (config.test) {
config.test.include = [
'**/src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)',
'src/jsx/hooks/dom.test.tsx',
]
}
export default config
12 changes: 12 additions & 0 deletions .vitest.config/jsx-runtime-dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import config from '../vitest.config'
config.esbuild = {
jsx: 'automatic',
jsxImportSource: __dirname + '/../src/jsx/dom',
}
if (config.test) {
config.test.include = [
'**/src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)',
'src/jsx/hooks/dom.test.tsx',
]
}
export default config
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[![Discord badge](https://img.shields.io/discord/1011308539819597844?label=Discord&logo=Discord)](https://discord.gg/KMh2eNSdxV)

Hono - _**\[\] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for the Edges.
It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Lagon, AWS Lambda, Lambda@Edge, and Node.js.
It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, AWS Lambda, Lambda@Edge, and Node.js.

Fast, but not only fast.

Expand All @@ -49,7 +49,7 @@ npm create hono@latest my-app

- **Ultrafast** 🚀 - The router `RegExpRouter` is really fast. Not using linear loops. Fast.
- **Lightweight** 🪶 - The `hono/tiny` preset is under 14kB. Hono has zero dependencies and uses only the Web Standard API.
- **Multi-runtime** 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, Lagon, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
- **Multi-runtime** 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
- **Batteries Included** 🔋 - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
- **Delightful DX** 😃 - Super clean APIs. First-class TypeScript support. Now, we've got "Types".

Expand Down
Binary file added benchmarks/query-param/bun.lockb
Binary file not shown.
Binary file added bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install.lockfile]
print = "yarn"
4 changes: 2 additions & 2 deletions deno_dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[![Discord badge](https://img.shields.io/discord/1011308539819597844?label=Discord&logo=Discord)](https://discord.gg/KMh2eNSdxV)

Hono - _**\[\] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for the Edges.
It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Lagon, AWS Lambda, Lambda@Edge, and Node.js.
It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, AWS Lambda, Lambda@Edge, and Node.js.

Fast, but not only fast.

Expand All @@ -49,7 +49,7 @@ npm create hono@latest my-app

- **Ultrafast** 🚀 - The router `RegExpRouter` is really fast. Not using linear loops. Fast.
- **Lightweight** 🪶 - The `hono/tiny` preset is under 14kB. Hono has zero dependencies and uses only the Web Standard API.
- **Multi-runtime** 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, Lagon, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
- **Multi-runtime** 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
- **Batteries Included** 🔋 - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
- **Delightful DX** 😃 - Super clean APIs. First-class TypeScript support. Now, we've got "Types".

Expand Down
19 changes: 19 additions & 0 deletions deno_dist/adapter/deno/deno.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare namespace Deno {
/**
* Creates a new directory with the specified path.
*
* @param path The path to create a directory.
* @param options Options for creating a directory.
* @returns A promise that resolves when the directory is created.
*/
export function mkdir(path: string, options?: { recursive?: boolean }): Promise<void>

/**
* Write a new file, with the specified path and data.
*
* @param path The path to the file to write.
* @param data The data to write to the file.
* @returns A promise that resolves when the file is written.
*/
export function writeFile(path: string, data: Uint8Array): Promise<void>
}
1 change: 1 addition & 0 deletions deno_dist/adapter/deno/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { serveStatic } from './serve-static.ts'
export { toSSG, denoFileSystemModule } from './ssg.ts'
1 change: 1 addition & 0 deletions deno_dist/adapter/deno/serve-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { open } = Deno
export type ServeStaticOptions<E extends Env = Env> = {
root?: string
path?: string
mimes?: Record<string, string>
rewriteRequestPath?: (path: string) => string
onNotFound?: (path: string, c: Context<E>) => void | Promise<void>
}
Expand Down
27 changes: 27 additions & 0 deletions deno_dist/adapter/deno/ssg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { toSSG as baseToSSG } from '../../helper/ssg/index.ts'
import type { FileSystemModule, ToSSGAdaptorInterface } from '../../helper/ssg/index.ts'

/**
* @experimental
* `denoFileSystemModule` is an experimental feature.
* The API might be changed.
*/
export const denoFileSystemModule: FileSystemModule = {
writeFile: async (path, data) => {
const uint8Data =
typeof data === 'string' ? new TextEncoder().encode(data) : new Uint8Array(data)
await Deno.writeFile(path, uint8Data)
},
mkdir: async (path, options) => {
return Deno.mkdir(path, { recursive: options?.recursive ?? false })
},
}

/**
* @experimental
* `toSSG` is an experimental feature.
* The API might be changed.
*/
export const toSSG: ToSSGAdaptorInterface = async (app, options) => {
return baseToSSG(app, denoFileSystemModule, options)
}
9 changes: 0 additions & 9 deletions deno_dist/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ class ClientRequestImpl {
}
}

if (args.queries) {
for (const [k, v] of Object.entries(args.queries)) {
for (const v2 of v) {
this.queryParams ||= new URLSearchParams()
this.queryParams.append(k, v2)
}
}
}

if (args.form) {
const form = new FormData()
for (const [k, v] of Object.entries(args.form)) {
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Hono } from '../hono.ts'
import type { Schema } from '../types.ts'
import type { HasRequiredKeys } from '../utils/types.ts'

type HonoRequest = typeof Hono.prototype['request']
type HonoRequest = (typeof Hono.prototype)['request']

export type ClientRequestOptions<T = unknown> = keyof T extends never
? {
Expand Down

0 comments on commit 2c44ad7

Please sign in to comment.